c# - I set the namespace but I I don't get the correct xml -


i have following code:

xnamespace xsins = xnamespace.get("http://www.w3.org/2001/xmlschema-instance");             xnamespace ns = xnamespace.get("http://xyz.com/2006/");             xdocument doc = new xdocument(                 new xdeclaration("1.0", "utf-8", null),                 new xelement(ns + "node",                     new xattribute(xnamespace.xmlns + "xsi", xsins),                     new xattribute(xsins + "schemalocation",                         "http://aaa.com/bbb.xsd")             ));               xelement newelement = new xelement(ns + "principalnode",                 new xattribute(ns + "attributte01", "value attributte01"),                 new xattribute(ns + "attributte02", "value attributte02"),                 new xelement(ns + "subnode01", " value subnode01"),                 new xelement(ns + "subnode02", " value subnode02"));              doc.root.add(newelement); 

but result is:

<?xml version="1.0" encoding="utf-8"?> <node xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="http://aaa.com/bbb.xsd" xmlns="http://aaa.com/bbb">   <principalnode p3:attributte01="value attributte01" p3:attributte02="value attributte02" xmlns:p3="http://aaa.com/bbb">     <p3:subnode01> value subnode01</p3:subnode01>     <p3:subnode02> value subnode02</p3:subnode02>   </principalnode> </node> 

i xmlns:p3 , p3.

thanks.

well, problem use "ns" in attributes , need use in xelement, no in xattribute.


Comments

Popular posts from this blog

blackberry 10 - how to add multiple markers on the google map just by url? -

php - guestbook returning database data to flash -

delphi - Dynamic file type icon -