I’m trying to make a batch file to pull data out of a file and set it as a variable.
The tricky part is I need to read a XML file, and I only need the data between the quotes of the following line…
narrative=”I only need this text here”
The text in that line can also contain spaces, brackets, slashes, dashes and colons.
OR, as per Razor’s suggestion, vbscript (or another language) could do a readall and probably solve the problem:
‘==== begin vbscript “xmlfind”
if wscript.arguments.count<1 then
wscript.echo “Usage: XMLFIND file.xml targetstring”
wscript.quit
end if
targ=wscript.arguments(1)
set fso=createobject(“scripting.filesystemobject”)
set test=fso.opentextfile(wscript.arguments(0),1)
z=test.readall
‘remove lcase() from foll line to observe case in search
point1=instr(lcase(z),lcase(targ))
if point1=0 then
wscript.echo “NOT FOUND: string: “&targ;
wscript.quit
end if
point1=point1+len(targ)
found=ltrim(mid(z,point1))
quote=left(found,1)
found=mid(found,2)
point2=instr(found,quote)
if point2>0 then
found=left(found,point2-1)
end if
wscript.echo chr(34)&found;&chr;(34)
‘===== end vbscript