0

I am trying to append xml file using vb script. Below is the code I wrote:

Dim xmlDoc
Dim objRoot
Dim objRecord
Dim objFieldValue
Set xmlDoc = _
CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = "False"
xmlDoc.Load("C:\Temp\Scripts_products.xml")

Set objRoot = xmlDoc.documentElement

Set objRecord = _
xmlDoc.createElement("Features")
objRoot.appendChild objRecord

Set objFieldValue = _
xmlDoc.createElement("ComputerName")
objFieldValue.Text = "atl-ws-100"
objRecord.appendChild objFieldValue

Set objFieldValue = _
xmlDoc.createElement("AuditDate")
objFieldValue.Text = Date
objRecord.appendChild objFieldValue

xmlDoc.Save "C:\Temp\Scripts_products.xml"

Below is the output I am getting:

</Product>
<Features xmlns=""><ComputerName>atl-ws-100</ComputerName>      <AuditDate>1/19/2015</AuditDate></Features>
</Products>

How do I get of "" (Feature xmlns instead of Feature xmlns="") which is coming in the feature tag.

3
  • 1
    It should be ... what? Commented Jan 20, 2015 at 22:38
  • That was a typo, sorry for that! Well, I just need <Feature xmlns> Instead, I am getting <Features xmlns=""> So, how do I achieve desired output? Commented Jan 22, 2015 at 8:54
  • Possible duplicate of How to avoid xmlns attribute when creating XML element using vbscript?. You get this behavior when an ancestor node defines a (default) namespace. Commented Jan 22, 2015 at 9:49

0

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.