471,123 Members | 791 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,123 software developers and data experts.

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.


Nov 12 '05 #1
2 6985
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
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="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 Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.