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.Create Element("FirstE lement");
myxmlfile.SetAt tribute("xmlns" , "http://www.server.com/XMLSchema");
myxmlfile.SetAt tribute("xmlns: xs", "http://www.w3.org/2001/XMLSchema-
instance");
myxmlfile.SetAt tribute("xs:sch emaLocation", "http://www.server.com/
XMLSchema myxml.xsd");
document.Append Child(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:schemaLocati on="http://
www.server.com/XMLSchema myxml.xsd">
Specifically, my problem is with line,
myxmlfile.SetAt tribute("xs:sch emaLocation", "http://www.server.com/
XMLSchema myxml.xsd");
When this line is excuted the xs:schemaLocati on, 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