1

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?

1
  • I updated your title to better fit the described problem. Commented Mar 18, 2015 at 12:34

1 Answer 1

2

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.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.