By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,281 Members | 2,216 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,281 IT Pros & Developers. It's quick & easy.

How to add xsi:schemaLocation attribute to XML element

P: n/a
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.


Nov 12 '05 #1
Share this Question
Share on Google+
2 Replies

P: n/a
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


Nov 12 '05 #2

P: n/a
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:

<Content id="Content0">
xmlns=""> ...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.