Home > Net >  How can I use special character in Document.createElement() - VBA DOM XML
How can I use special character in Document.createElement() - VBA DOM XML

Time:11-30

I want to make an XML file using XML DOM in VBA and I can't find a way to set element name using special character. I need it to be named "a:something" but when I add the colon it gives me an error. How should I proceed? Thank you for any help.

CodePudding user response:

The fact that you want your element name to be "a:something" presumably means that you want it to have a namespace prefix of "a" and a local name of "something". To create an element in a namespace you need to use the two- or three-argument form of the CreateElement method, specifying the namespace URI and prefix as well as the local name.

For example doc.CreateElement("a:something", "http://somthing-uri"); where http://somthing-uri is the required namespace.

  • Related