Reputation: 125
I'm working with the XMLDocument class in VB.net.
I want to get element with name "a:Product", but following code:
dim doc as new XMLDocument
dim pr as XMLElement = doc.CreateElement("a:product")
pr.InnerText = "123"
doc.AppendChild(pr)
return element in XML without "a:":
<product>123</product>
Where do I go wrong?
Upvotes: 1
Views: 2821
Reputation: 7773
Use this instead:
dim pr as XMLElement = doc.CreateElement("a:product", namespaceURI);
Where namespaceURI
is the namespace represented by the alias "a". This is usually something like "http://schema.example.com/blahblah". Just look it up in your XML file.
Upvotes: 2