How to resolve the algorithm XML/XPath step by step in the VBScript programming language

Published on 12 May 2024 09:40 PM

How to resolve the algorithm XML/XPath step by step in the VBScript programming language

Table of Contents

Problem Statement

Perform the following three XPath queries on the XML Document below: XML Document:

Let's start with the solution:

Step by Step solution about How to resolve the algorithm XML/XPath step by step in the VBScript programming language

Source code in the vbscript programming language

Set objXMLDoc = CreateObject("msxml2.domdocument")

objXMLDoc.load("In.xml")

Set item_nodes = objXMLDoc.selectNodes("//item")
i = 1
For Each item In item_nodes
	If i = 1 Then
		WScript.StdOut.Write item.xml
		WScript.StdOut.WriteBlankLines(2)
		Exit For
	End If
Next

Set price_nodes = objXMLDoc.selectNodes("//price")
list_price = ""
For Each price In price_nodes
	list_price = list_price & price.text & ", "
Next
WScript.StdOut.Write list_price
WScript.StdOut.WriteBlankLines(2)

Set name_nodes = objXMLDoc.selectNodes("//name")
list_name = ""
For Each name In name_nodes
	list_name = list_name & name.text & ", "
Next
WScript.StdOut.Write list_name
WScript.StdOut.WriteBlankLines(2)

  

You may also check:How to resolve the algorithm Tokenize a string step by step in the Genie programming language
You may also check:How to resolve the algorithm Permutations step by step in the Erlang programming language
You may also check:How to resolve the algorithm Named parameters step by step in the SenseTalk programming language
You may also check:How to resolve the algorithm Bulls and cows step by step in the Ceylon programming language
You may also check:How to resolve the algorithm Ulam spiral (for primes) step by step in the Nim programming language