i'm guessing pretty straightforward i'm not versed in handling xml data.
i have vbscript code processes xml data third party in format.
<data> <thing1>some thing</thing1> <thing2>some other thing</thing2> <parameter> <parametername>customthing1</paramtername> <parametervalue>this data want</parametervalue> </parameter> </data>
previously, data came in thing1 or thing2. have had add custom field data, , third party sending in 'parameter' format.
i old data so: (objxmlrequest msxml2.domdocument object)
thing1 = objxmlrequest.documentelement.selectsinglenode("thing1").firstchild.nodevalue
now need value customthing1, don't want pull 'parametervalue' because if add custom field in future problem. need make sure i'm getting paramtervalue parametername = customthing1. how that?
based on this: find parameter customthing1 parametername , access parametervalue:
dim objmsxml : set objmsxml = createobject("msxml2.domdocument") objmsxml.setproperty "selectionlanguage", "xpath" objmsxml.async = false objmsxml.load ".\38512955.xml" if 0 = objmsxml.parseerror dim sxpath : sxpath = "/data/parameter[parametername=""customthing1""]/parametervalue" dim ndx : set ndx = objmsxml.selectsinglenode(sxpath) if ndx nothing wscript.echo sxpath, "failed" else wscript.echo ndx.tagname, ndx.text end if else wscript.echo objmsxml.parseerror.reason end if
output:
cscript 38512955.vbs parametervalue data want
Comments
Post a Comment