troubleshooting Question

Trying to change an XML file automatically with VBScript to change defaults in OpenOffice

Avatar of PRSEXPERT
PRSEXPERTFlag for United States of America asked on
XMLVB Script
5 Comments1 Solution987 ViewsLast Modified:
I am trying to get this script to work, and I am now asking for assistance.

It will replace the value with value_a, but it will not tag correctly.

Please assist.

Thanks

I have attached the xml file and the vbscript is:


Dim XmlDoc, value_a, value_b, value_c
value_a = "<value>MS Office 97<"&"/value>"
value_c = value_a

Set XmlDoc = CreateObject("Msxml2.DOMDocument.4.0")
XmlDoc.async = False
If XmlDoc.load("writer.xml") Then
    XmlDoc.setProperty "SelectionLanguage", "XPath"
    XmlDoc.setProperty "SelectionNamespaces","xmlns:oor='" & XmlDoc.documentElement.namespaceURI & "'"
    Set value_b = XmlDoc.selectsinglenode("oor:data/oor:component-data[attribute::oor:name='Setup']/node[attribute::oor:name='Office']/node[attribute::oor:name='Factories']/node[attribute::oor:name='com.sun.star.text.TextDocument']/prop[attribute::oor:name='ooSetupFactoryDefaultFilter']")
        If Not value_b Is Nothing Then
            WScript.Echo "Found value " & value_b.text
            value_b.text = value_c
            strResult = XmlDoc.save("file2.xml")
        Else
            WScript.Echo "value element not found."
        End If
    Else
        WScript.Echo "Error parsing XML: " & XmlDoc.parseError.reason
End If
 writer.xml
file2.xml
ASKER CERTIFIED SOLUTION
PRSEXPERT

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Join our community to see this answer!
Unlock 1 Answer and 5 Comments.
Start Free Trial
Learn from the best

Network and collaborate with thousands of CTOs, CISOs, and IT Pros rooting for you and your success.

Andrew Hancock - VMware vExpert
See if this solution works for you by signing up for a 7 day free trial.
Unlock 1 Answer and 5 Comments.
Try for 7 days

”The time we save is the biggest benefit of E-E to our team. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange.

-Mike Kapnisakis, Warner Bros