473,226 Members | 1,583 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,226 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 7396
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: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: fareedcanada | last post by:
Hello I am trying to split number on their count. suppose i have 121314151617 (12cnt) then number should be split like 12,13,14,15,16,17 and if 11314151617 (11cnt) then should be split like...
0
by: stefan129 | last post by:
Hey forum members, I'm exploring options for SSL certificates for multiple domains. Has anyone had experience with multi-domain SSL certificates? Any recommendations on reliable providers or specific...
1
by: davi5007 | last post by:
Hi, Basically, I am trying to automate a field named TraceabilityNo into a web page from an access form. I've got the serial held in the variable strSearchString. How can I get this into the...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
0
by: Aftab Ahmad | last post by:
Hello Experts! I have written a code in MS Access for a cmd called "WhatsApp Message" to open WhatsApp using that very code but the problem is that it gives a popup message everytime I clicked on...

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.