Hi
I have wrote a method in my C# class with the following code, to
create an XMl file.
The root element is suppose to have 3 attibutes. I can not get
attributes to appear correctly.
XmlDocument document = new XmlDocument();
XmlElement myxmlfile = document.CreateElement("FirstElement");
myxmlfile.SetAttribute("xmlns", "http://www.server.com/XMLSchema");
myxmlfile.SetAttribute("xmlns:xs", "http://www.w3.org/2001/XMLSchema-
instance");
myxmlfile.SetAttribute("xs:schemaLocation", "http://www.server.com/
XMLSchema myxml.xsd");
document.AppendChild(myxmlfile);
This is how the XML document prints out when I compile and run the
code..
<?xml version="1.0" encoding="utf-8"?>
<FirstElement xmlns="http://www.server.com/XMLSchema" xmlns:xs="http://
www.w3.org/2001/XMLSchema-instance" schemaLocation="http://
www.server.com/XMLSchema myxml.xsd">
But I need to make it look like this.
<?xml version="1.0" encoding="utf-8"?>
<FirstElement xmlns="http://www.server.com/XMLSchema" xmlns:xs="http://
www.w3.org/2001/XMLSchema-instance" xs:schemaLocation="http://
www.server.com/XMLSchema myxml.xsd">
Specifically, my problem is with line,
myxmlfile.SetAttribute("xs:schemaLocation", "http://www.server.com/
XMLSchema myxml.xsd");
When this line is excuted the xs:schemaLocation, becomes
schemaLocation. The "xs:" is being dropped.
What do you do to fix this problem.
why doesn't the SetAttribute() method work correctly?
What do have to do correct this problem.
thanks,
nitadmin