467,877 Members | 950 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 467,877 developers. It's quick & easy.

How to add xsi:schemaLocation attribute to XML element

Hi all,

I am trying to serialize a C# object into a XML document
using "XmlSerializer" class. One of the elements of the XML document
needs a "xsi:schemaLocation" attribute. I am not sure how to add this
to the XML element
Please help me with if you can.

Thanks,
kaush

Nov 12 '05 #1
  • viewed: 6519
Share:
2 Replies
JMD
The root element of the document can contain, along with all the xmlns
stuff, an attribute called
xsi:schemaLocation="namespaceURI filename.xsd"

There are two tokens inside the single string. This is a hint for the
validator to know where to find a physical xsd file to go with that
namespace.

--John

Nov 12 '05 #2
If I add it to the root element of the element for which I need to add
the xsi:schemaLocation attribute, it does not seem to be working.

Below is the partial XML doc:

<ProcessMessage
xmlns="http://www.starstandards.org/webservices/2003/12/transport">
<payload
xmlns="http://www.starstandards.org/webservices/2003/12/transport">
<Content id="Content0">
<rey_ServiceStatusRequest
xmlns="http://www.starstandards.org/STAR"> ...this goes on .
"rey_ServiceStatusRequest" parent is "Content"
I need to add the xsi:schemaLocation attribute to
"rey_ServiceStatusRequest" element. Actually this XML document I
produce it from a C# object. I use XMLSERIALIZE class to serialize the
object into XML document. For some reason I am not able to add the
xsi:schemaLocation attribute. I am able to add schemaLocation attribute
without the "xsi" prefix. I am able to do this using
//[System.Xml.Serialization.XmlAttributeAttribute(Dat aType="anyURI")].
This declaration is for a particular memeber of the class.

Could you please help me out ?

The only other option I have is to construct the XML doc "element" by
"element" which I do not want to do.

Please help

Nov 12 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Sarah Tegtmeier | last post: by
reply views Thread by Ron James | last post: by
reply views Thread by kolja2003 | last post: by
2 posts views Thread by grochmal | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.