Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBScript, XML, adding an attribute to root element

Status
Not open for further replies.

fredmartinmaine

IS-IT--Management
Mar 23, 2015
79
US
I'm trying to create a new XML doc; for the moment just the root element. I'd like the output to look like this:

<ImportInspectionsRequest xmlns="<ImportInspectionsRequest>

Here's the code:

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
Set objRoot = xmlDoc.createElement("ImportInspectionsRequest")
objRoot.SetAttribute "xmlns","xmlDoc.appendChild objRoot
xmlDoc.Save "test.xml"

The script runs without error. The xml is is created and has the node, but no attribute.
Any idea why not? SetAttribute must have done something or it would have squawked.

Apparently not related to being the root element. Same happens elsewhere, several levels in.

Fred
 
Foolish me. The attributes are there. They don't appear viewing the XML file in some browsers. Bah.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top