Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / XML / November 2005

Tip: Looking for answers? Try searching our database.

How to add xsi:schemaLocation attribute to XML element

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
kaush - 04 Nov 2005 22:51 GMT
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
JMD - 05 Nov 2005 00:55 GMT
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
kaush - 05 Nov 2005 02:18 GMT
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(DataType="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

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.