Home. 
.

transparent

transparent

transparent

Altova Mailing List Archives


extra xmlns

From: stanley@-----------.---------.---
To: NULL
Date: 2/1/2005 10:57:00 AM
hi all
I have the following code in c++, when I run the code I get 
an extra xmlns="" attribute in the children elements

i understood from a previouse Questions in this newsgroup that i am using a 
default namespace for the root element

but i am still getting problems implement it the right way 
my code:
IXMLDOMDocumentPtr XMLEmpDoc;
IXMLDOMElementPtr    XMLRootElem;
IXMLDOMElementPtr    XMLChildElem;
IXMLDOMAttributePtr   XMLAttr;

XMLEmpDoc.CreateInstance("Microsoft.XMLDOM");

XMLRootElem= XMLEmpDoc->createNode(1, "employee", 
"x-schema:file:///E:\TK_SQL\EMPLOYEE-SCHEMA.XML"  );

XMLEmpDoc->appendChild(XMLRootElem);

//Root attributes:
XMLAttr= XMLEmpDoc->createAttribute("FIRST_NAME");
XMLAttr->value = "BILL";
XMLRootElem->setAttributeNode(XMLAttr);
XMLAttr.Release();

XMLAttr= XMLEmpDoc->createAttribute("LAST_NAME");
XMLAttr->value = "CLINTON";
XMLRootElem->setAttributeNode(XMLAttr);
XMLAttr.Release();

//add a child element with NO xmlns attributes!!!
XMLChildElem= XMLEmpDoc->createElement("address");
XMLEmpDoc->documentElement->appendChild(XMLElement);

//child attributes
XMLAttr= XMLEmpDoc->createAttribute("city");
XMLAttr->value = "new-york city";
XMLElement->setAttributeNode(XMLAttr);
XMLAttr.Release();

XMLAttr= XMLEmpDoc->createAttribute("street");
XMLAttr->value = "42 st";
XMLElement->setAttributeNode(XMLAttr);

XMLEmpDoc->save("MyXML.xml");

the wanted result:
<employee xmlns="x-schema:file:///E:\TK_SQL\EMPLOYEE-SCHEMA.XML">
FIRST_NAME = "BILL"
LAST_NAME = "CLINTON">
<address CITY= "NEW-YORK CITY" STREET = "42 st" />
</employee>

what is wrong here ?
if someone can explain me the corect way of implementation it will be great
thanks a lot
stanley




transparent
Print
Mail
Like It
Disclaimer
.

These Archives are provided for informational purposes only and have been generated directly from the Altova mailing list archive system and are comprised of the lists set forth on www.altova.com/list/index.html. Therefore, Altova does not warrant or guarantee the accuracy, reliability, completeness, usefulness, non-infringement of intellectual property rights, or quality of any content on the Altova Mailing List Archive(s), regardless of who originates that content. You expressly understand and agree that you bear all risks associated with using or relying on that content. Altova will not be liable or responsible in any way for any content posted including, but not limited to, any errors or omissions in content, or for any losses or damage of any kind incurred as a result of the use of or reliance on any content. This disclaimer and limitation on liability is in addition to the disclaimers and limitations contained in the Website Terms of Use and elsewhere on the site.

.
.

transparent

transparent