Yoavo wrote:
I am trying to add an XmlElement to my XML file:
XmlDocument aDoc = new Xml Document();
aDoc.Load("MyFile.xml");
XmlElement el = aDoc.CreateElement("Cim:Attr");
When I append this element to a node, the name of element is "Attr" only.
How can I add an XmlElement and recieve the full name (Cim:Attr) ?
You need to know the namespace URL you want to create the element in,
just a prefix does not suffice, if you know the URL then you can use e.g.
XmlElement el = aDoc.CreateElement("Cim", "Attr", "http://example.com/");
As you already load an existing XML document from a file the prefix Cim
might be bound to a URL in that document so depending on what you want
to achieve
XmlElement el = aDoc.CreateElement("Cim", "Attr",
aDoc.DocumentElement.GetNamespaceOfPrefix("Cim"));
might do (without any need to name the URL in your code literally).
--
Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/