.net - creating xml file with namespaces -
i'm trying create xml file:
<?xml version="1.0"?> <order xmlns="urn:schemas-basda-org:2000:purchaseorder:xdr:3.01" xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:schemalocation="urn:schemas-basdaorg:2000:purchaseorder:xdr:3.01order-v3.xsd">
i have next code:
dim xsi xnamespace = "http://www.w3.org/2001/xmlschema-instance" dim schemalocation xnamespace = "urn:schemas-basdaorg:2000:purchaseorder:xdr:3.01order-v3.xsd" dim order xnamespace = "urn:schemas-basda-org:2000:purchaseorder:xdr:3.01" dim root new xelement("root", new xattribute("order", order.namespacename), _ new xattribute(xnamespace.xmlns + "xsi", xsi.namespacename), _ new xattribute(xsi.namespacename + "schemalocation", schemalocation.namespacename), _ new xelement("child", _ new xelement("differentchild", "other content")), _ new xelement("child2", "c2 content"), _ new xelement("child3", "c3 content"))
however when run code next error:
xmlexception unhanded ':' character, hexadecimal value 0x3a, cannot included in name.
edit
ok got namespaces work next code:
dim xsi xnamespace = "http://www.w3.org/2001/xmlschema-instance" dim schemalocation xnamespace = "urn:schemas-basdaorg:2000:purchaseorder:xdr:3.01order-v3.xsd" dim order xnamespace = "urn:schemas-basda-org:2000:purchaseorder:xdr:3.01" dim root new xelement(order + "order", _ new xattribute(xnamespace.xmlns + "xsi", xsi.namespacename), new xattribute(xnamespace.xmlns + "schemalocation", schemalocation), new xelement("orderhead", _ new xelement("schema", new xelement("version", "3.05")), new xelement("parameters", new xelement("language", "en-gb"), new xelement("decimalseparator", "."), new xelement("precision", "20.3")), _ new xelement("ordertype", "purchase order", new xattribute("code", "puo"))), _
but in xml have:
<orderhead xmlns=""> <schema> <version>3.05</version> </schema> <parameters>
is there way of getting rid of blank xmlns="" within orderhead tag?
what this:
dim order xnamespace = "urn:schemas-basda-org:2000:purchaseorder:xdr:3.01" dim root new xelement( order + "order", new xelement(order + "child", _ new xelement(order + "differentchild", "other content")), _ new xelement(order + "child2", "c2 content"), _ new xelement(order + "child3", "c3 content"))
sorry, don't have time test right now.
.net xml vb.net xml-namespaces
No comments:
Post a Comment