VB.NET XML Attribute does not appear correctly -


i have output this:

<ricette xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xsi:nonamespaceschemalocation="xml.xsd"> 

but obtain this:

<ricette xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" nonamespaceschemalocation="xml.xsd"> 

xsi:nonamespaceschemalocation doesn't appear correctly

here piece of code:

dim xmlnsxsiattribute xmlattribute = myxmldocument.createattribute("xmlns:xsi") xmlnsxsiattribute.value = "http://www.w3.org/2001/xmlschema-instance" dim xsiattribute xmlattribute = myxmldocument.createattribute("xsi:nonamespaceschemalocation") xsiattribute.value = "xml.xsd" node.attributes.append(xmlnsxsiattribute) node.attributes.append(xsiattribute) 

how can solve this?

you can use xmlelement.setattribute() method add namespaced attribute element :

.... node.setattribute("xmlns:xsi", "http://www.w3.org/2001/xmlschema-instance") node.setattribute("nonamespaceschemalocation", "http://www.w3.org/2001/xmlschema-instance", "xml.xsd") 

from msdn :

public virtual string setattribute(   string localname,   string namespaceuri,   string value ) 

sets value of attribute specified local name , namespace uri.


Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -