Quote from PaulJonestindall on September 16, 2021, 12:25 pmThere's a recent post about a JSON plugin.
Anyone know of a function or plugin that will parse XML files?
There's a recent post about a JSON plugin.
Anyone know of a function or plugin that will parse XML files?

Quote from emo on September 16, 2021, 12:46 pmHi @pauljonestindall , you can create a VBScript function to retrive de XML data easy like in this example:
https://vbscriptbasicconcepts.blogspot.com/p/parsing-xml-using-vbscript-xml-object.html
Hi @pauljonestindall , you can create a VBScript function to retrive de XML data easy like in this example:
https://vbscriptbasicconcepts.blogspot.com/p/parsing-xml-using-vbscript-xml-object.html

Quote from HPW on September 16, 2021, 1:15 pmHello,
Maybe a bit offtopic, but you may have a look at newLisp (and hpwNewLisp):
http://www.newlisp.org/downloads/newlisp_manual.html#xml-parse
http://www.newlisp.org/downloads/newlisp_manual.html#json-parse
Regards
Hans-Peter
Hello,
Maybe a bit offtopic, but you may have a look at newLisp (and hpwNewLisp):
http://www.newlisp.org/downloads/newlisp_manual.html#xml-parse
http://www.newlisp.org/downloads/newlisp_manual.html#json-parse
Regards
Hans-Peter
Quote from PaulJonestindall on September 16, 2021, 1:28 pm@emmanuel-fernandez
Thanks for the link but there seems to be a problem with it. It can't connect.
Thanks for the link but there seems to be a problem with it. It can't connect.

Quote from emo on September 16, 2021, 5:37 pmQuote from PaulJonestindall on September 16, 2021, 1:28 pm@emmanuel-fernandez
Thanks for the link but there seems to be a problem with it. It can't connect.
Hi, @pauljonestindall, the link is working in my country (spain) perhaps your country is banned from that blog.
Basically here is one of the examples:
Let us consider the following XML Document:
<?xml version="1.0"?> <compactdiscs> <compactdisc> <artist type="individual">Frank Sinatra</artist> <title numberoftracks="4">In The Wee Small Hours</title> <tracks> <track>In The Wee Small Hours</track> <track>Mood Indigo</track> <track>Glad To Be Unhappy</track> <track>I Get Along Without You Very Well</track> </tracks> <price>$12.99</price> </compactdisc> <compactdisc> <artist type="band">The Offspring</artist> <title numberoftracks="5">Americana</title> <tracks> <track>Welcome</track> <track>Have You Ever</track> <track>Staring At The Sun</track> <track>Pretty Fly (For A White Guy)</track> </tracks> <price>$12.99</price> </compactdisc>Program to read the data present in XML file:
Option Explicit Dim strFilePath, strQuery strFilePath = split(wscript.scriptFullName, wscript.scriptName)(0) & "DATA.XML" '============================================================================================== 'get All the tracks of the Album - Americana strQuery = "//compactdisc[title/text() = 'Americana']/tracks/track" fn_readXML strFilePath, strQuery 'get Artist type of Artist who has produced the Album 'In The Wee Small Hours' strQuery = "//compactdisc[title/text()='In The Wee Small Hours']/artist/@type" fn_readXML strFilePath, strQuery 'Artist Name of the Track 'Glad To Be Unhappy' strQuery = "//compactdisc[tracks/track/text() = 'Glad To Be Unhappy']/artist/text()" fn_readXML strFilePath, strQuery 'Display the 3rd Track of each disc strQuery = "//track[position()=3]" fn_readXML strFilePath, strQuery 'Last track in each disk strQuery = "//track[last()]" fn_readXML strFilePath, strQuery Function fn_readXML(strFilePath, strQuery) Dim objXML, objError, objNodes, i set objXML = CreateObject("MSXML2.DomDocument") objXML.load strFilePath objXML.async = False objXML.setProperty "SelectionLanguage", "XPath" set objError = objXML.parseError With objError If .errorCode = 0 Then Set objNodes = objXML.selectNodes(strQuery) For i = 0 to objNodes.length - 1 step 1 msgbox objNodes.item(i).nodeName & " --- " & objNodes.item(i).text Next Else msgbox "XML Document could not be parsed!!!" & vbCrLf &_ "ErrorCode: " & .errorCode & vbCrLf &_ "Line: " & .line & vbCrLf &_ "Reason: " & .reason & vbCrLf &_ "Path: " & .URL End If End With set objXML = Nothing End Function
Quote from PaulJonestindall on September 16, 2021, 1:28 pmThanks for the link but there seems to be a problem with it. It can't connect.
Hi, @pauljonestindall, the link is working in my country (spain) perhaps your country is banned from that blog.
Basically here is one of the examples:
Let us consider the following XML Document:
<?xml version="1.0"?>
<compactdiscs>
<compactdisc>
<artist type="individual">Frank Sinatra</artist>
<title numberoftracks="4">In The Wee Small Hours</title>
<tracks>
<track>In The Wee Small Hours</track>
<track>Mood Indigo</track>
<track>Glad To Be Unhappy</track>
<track>I Get Along Without You Very Well</track>
</tracks>
<price>$12.99</price>
</compactdisc>
<compactdisc>
<artist type="band">The Offspring</artist>
<title numberoftracks="5">Americana</title>
<tracks>
<track>Welcome</track>
<track>Have You Ever</track>
<track>Staring At The Sun</track>
<track>Pretty Fly (For A White Guy)</track>
</tracks>
<price>$12.99</price>
</compactdisc>
Program to read the data present in XML file:
Option Explicit
Dim strFilePath, strQuery
strFilePath = split(wscript.scriptFullName, wscript.scriptName)(0) & "DATA.XML"
'==============================================================================================
'get All the tracks of the Album - Americana
strQuery = "//compactdisc[title/text() = 'Americana']/tracks/track"
fn_readXML strFilePath, strQuery
'get Artist type of Artist who has produced the Album 'In The Wee Small Hours'
strQuery = "//compactdisc[title/text()='In The Wee Small Hours']/artist/@type"
fn_readXML strFilePath, strQuery
'Artist Name of the Track 'Glad To Be Unhappy'
strQuery = "//compactdisc[tracks/track/text() = 'Glad To Be Unhappy']/artist/text()"
fn_readXML strFilePath, strQuery
'Display the 3rd Track of each disc
strQuery = "//track[position()=3]"
fn_readXML strFilePath, strQuery
'Last track in each disk
strQuery = "//track[last()]"
fn_readXML strFilePath, strQuery
Function fn_readXML(strFilePath, strQuery)
Dim objXML, objError, objNodes, i
set objXML = CreateObject("MSXML2.DomDocument")
objXML.load strFilePath
objXML.async = False
objXML.setProperty "SelectionLanguage", "XPath"
set objError = objXML.parseError
With objError
If .errorCode = 0 Then
Set objNodes = objXML.selectNodes(strQuery)
For i = 0 to objNodes.length - 1 step 1
msgbox objNodes.item(i).nodeName & " --- " & objNodes.item(i).text
Next
Else
msgbox "XML Document could not be parsed!!!" & vbCrLf &_
"ErrorCode: " & .errorCode & vbCrLf &_
"Line: " & .line & vbCrLf &_
"Reason: " & .reason & vbCrLf &_
"Path: " & .URL
End If
End With
set objXML = Nothing
End Function

Quote from DaviddeArgentina on September 17, 2021, 12:24 am@emmanuel-fernandez
Hi overthere,
Take a look of the powershell enviroment.
It's easy and it does the job quickly.
see:
https://blog.victorsilva.com.uy/xml-powershell/
Greetings from Buenos Aires,
David de Argentina
Hi overthere,
Take a look of the powershell enviroment.
It's easy and it does the job quickly.
see:
https://blog.victorsilva.com.uy/xml-powershell/
Greetings from Buenos Aires,
David de Argentina

Quote from Vadim on September 17, 2021, 10:35 am
@pauljonestindall
There is a function for NeoBook\VisualNEO Win: XmlParse (Artyom Braineng). Maybe it will work for you. In the "Result" field the parser has to put the content between the tags, the opening one of which is specified in the "Key" field. In the example, "<index>value</index>" is what in place of "index" should be put in the key, and what in place of "value" is what the function will output as the parsing result. The syntax: "xmlParse" "xml file content" "key(index)" "Save value to a variable". If the xml key is not found or is written with an error, it does not output its value.
There is a function for NeoBook\VisualNEO Win: XmlParse (Artyom Braineng). Maybe it will work for you. In the "Result" field the parser has to put the content between the tags, the opening one of which is specified in the "Key" field. In the example, "<index>value</index>" is what in place of "index" should be put in the key, and what in place of "value" is what the function will output as the parsing result. The syntax: "xmlParse" "xml file content" "key(index)" "Save value to a variable". If the xml key is not found or is written with an error, it does not output its value.
Uploaded files: