xml - TXMLDocument->ChildNodes->Add() creates unwanted empty xmlns attribute -
this driving me crazy. need combine several xml classes 1 final document. defined federal government. after filling out each xml class (created using xml data binding wizard) appropriate values, need insert couple of classes child nodes. unfortunately way i'm doing creates empty (and not federal specifications) xmlns="" attribute. here's gist of code (with non-relevant pieces removed)
irsreturn = new txmldocument(getwindow()); irsreturn->domvendor = getdomvendor("msxml"); // not cross platform compatible irsreturnroot = getreturn(irsreturn); irsreturn->version = "1.0"; irsreturn->encoding = "utf-8"; irsreturnroot->returnversion = "2015v3.0"; irsreturnroot->setattribute("xmlns", ereturn_targetnamespace); irsreturnroot->setattribute("xmlns:xsd", ereturn_schema); irsreturnroot->setattribute("xmlns:efile", ereturn_targetnamespace); irsreturnheader = new txmldocument(getwindow()); irsreturnheader->domvendor = getdomvendor("msxml"); // not cross platform compatible irsretheadroot = getreturnheader(irsreturnheader); // fill out irsretheadroot fields ... irsreturnroot->childnodes->add(irsreturnheader->documentelement); irsreturn->xml->text = formatxmldata(irsreturn->xml->text); irsreturn->active = true; irsreturn->savetofile("irsreturntest.xml");
this works except returnheader child node gets unwanted xmlns="" attribute added so:
<?xml version="1.0"? encoding="utf-8"?> <return returnversion="2015v3.0" xmlns="http://www.irs.gov/efile" xmlns:xsd="http://www.w3.org/2001/xmlschema" xmlns:efile="http://www.irs.gov/efile"> <returnheader xmlns="" binaryattachmentcnt="0"> // details removed </returnheader> </return>
how can rid of unwanted namespace attribute after adding it, or better keep add() method adding in first place?
(i've tried turning off doautoprefix option code below , doesn't seem make difference.)
irsreturn->options = irsreturn->options >> doautoprefix;
Comments
Post a Comment