473,322 Members | 1,398 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 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.

Thanks,
kaush

Nov 12 '05 #1
2 7427
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Naresh Agarwal | last post by:
Hi I'm using SAX Parser of Xerces Java v2.4.0 for XML Parsing. I want to perform schema validations on the xml. The problem is that root element of XML document does not have...
1
by: Naresh Agarwal | last post by:
Hi I'm using SAX Parser of Xerces Java v2.4.0 for XML Parsing. I want to perform schema validations on the xml. The problem is that root element of XML document does not have...
0
by: Sarah Tegtmeier | last post by:
Hi I have a question about the correct use of the attribute xsi:schemaLocation. My programm has to process XML files where the value of this attribute causes some problems. The programm is...
0
by: Ron James | last post by:
I'm developing a GUI application in C#. I have a schema file (.XSD) and am able to serialize and deserialize the applications data using the schema file to an .XML file. (I'm using xsd.exe to...
0
by: kaushsoap | last post by:
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...
1
by: jean | last post by:
I am creating an xmldatadocument from an acess database with visual basic. Here is the header code I am using: Dim xmldcl As XmlDeclaration = myDoc.CreateXmlDeclaration("1.0", "UTF-8", "yes")...
0
by: kolja2003 | last post by:
Hi, I need to program the creation of the XML file of given structure. I try to do it through the serialization of class object. hence I need to write the class definition which will be serialized...
2
by: grochmal | last post by:
I am trying to use XmlSerializer to serialize a class I have created specifically for generating an XML file. The problem is that the XML file must contain a xsi:schemaLocation attribute in my...
0
by: spiceworm | last post by:
Hi all, I'm getting really confused how to solve this. I've got this class generated from XSD with xsd (from visual studio 2005) namespace gpx { using System.Xml.Serialization;
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

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.