c# - how to import node in XML -


parent xml

<order>      <class/>      <account>         <saving/>      </account> </order> 

i want import node parent xml

node:

 <data>      <address/>  </data> 

after importing, final xml as

<order>      <class/>      <account>         <saving/>      </account>      <data>          <address/>      </data> </order> 

please me here

i tried below:

 xmldocument doc = new xmldocument();  doc.loadxml(childxml.innerxml);  mlnode newnodedataset = doc.documentelement;  xmldocument xdoc = new xmldocument(); xdoc.loadxml(parentxml); xmlnode root = xdoc.documentelement;    xdoc.importnode(newnodedataset, true); 

it donesn't throwing error not importing node. doing wrong here?

all need add element existing document root using add method, seems:

var doc = new xdocument(     new xelement("order",         new xelement("class"),         new xelement("account",             new xelement("saving")         )     ) );  var element = new xelement("data", new xelement("address"));  doc.root.add(element); 

result (in doc):

<order>   <class />   <account>     <saving />   </account>   <data>     <address />   </data> </order> 

Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -