473,395 Members | 1,996 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,395 software developers and data experts.

xsi:schemaLocation in xmldatadocument class

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")
Dim newElem As XmlElement = myDoc.CreateElement("sender")
newElem.SetAttribute("schemaVersion", "1.0")
newElem.SetAttribute("xmlns", "http://www.somewhere.org")
newElem.SetAttribute("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance")
newElem.SetAttribute("xsi:schemaLocation", "http://www.somewhere.org
filename.xsd")
newElem.SetAttribute("name", "NewFile")
myDoc.AppendChild(newElem)
myDoc.InsertBefore(xmldcl, newElem)

The xml file created leaves off the :xsi prefix from the schema location.
The document then fails validation.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sender schemaVersion="1.0" xmlns="http://www.somewhere.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
schemaLocation="http://www.somewhere.org filename.xsd" name="Filename">

So close - but not right... what am I doing wrong?
Sincerely,
Jean
Nov 15 '05 #1
1 2329
you are using the setattribute overload which does not take in a namespace
uri, you should use

public virtual string SetAttribute(string, string, string);

detailts at:
http://msdn.microsoft.com/library/de...ibutetopic.asp

"jean" <je**@discussions.microsoft.com> wrote in message
news:93**********************************@microsof t.com...
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")
Dim newElem As XmlElement = myDoc.CreateElement("sender")
newElem.SetAttribute("schemaVersion", "1.0")
newElem.SetAttribute("xmlns", "http://www.somewhere.org")
newElem.SetAttribute("xmlns:xsi",
"http://www.w3.org/2001/XMLSchema-instance")
newElem.SetAttribute("xsi:schemaLocation", "http://www.somewhere.org filename.xsd")
newElem.SetAttribute("name", "NewFile")
myDoc.AppendChild(newElem)
myDoc.InsertBefore(xmldcl, newElem)

The xml file created leaves off the :xsi prefix from the schema location.
The document then fails validation.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<sender schemaVersion="1.0" xmlns="http://www.somewhere.org"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
schemaLocation="http://www.somewhere.org filename.xsd" name="Filename">

So close - but not right... what am I doing wrong?
Sincerely,
Jean

Nov 16 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

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...
2
by: kaush | 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...
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.