Altova Mailing List Archives>Archive Index >microsoft.public.xml Archive Home >Recent entries [Thread Prev] >Thread Next - Re: extra xmlns extra xmlnsTo: 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
| ||||||
| Company | Legal | Press | Partners | Careers | Sitemap | Contact Us | Altova Blog | Mobile | Full Site | |||
|
