WinBatch Tech Support Home

Database Search

If you can't find the information using the categories below, post a question over in our WinBatch Tech Support Forum.

TechHome

XML
plus
plus

Can't find the information you are looking for here? Then leave a message over on our WinBatch Tech Support Forum.

XML GetElementsByTagName Sample

 Keywords:  XML GetElementsByTagName MSXML2.DOMDocument.6.0 MSXML2 Node List LoadXML

xmldata = `<?xml version="1.0"?>`
xmldata = xmldata : `<catalog>`
xmldata = xmldata : `  <book id="bk101">`
xmldata = xmldata : `     <author>Gambardella, Matthew</author>`
xmldata = xmldata : `     <title>XML Developer's Guide</title>`
xmldata = xmldata : `     <genre>Computer</genre>`
xmldata = xmldata : `     <price>44.95</price>`
xmldata = xmldata : `     <publish_date>2000-10-01</publish_date>`
xmldata = xmldata : `     <description>An in-depth look at creating applications with XML.</description>`
xmldata = xmldata : `   </book>`
xmldata = xmldata : `   <book id="bk102">`
xmldata = xmldata : `      <author>Ralls, Kim</author>`
xmldata = xmldata : `      <title>Midnight Rain</title>`
xmldata = xmldata : `      <genre>Fantasy</genre>`
xmldata = xmldata : `      <price>5.95</price>`
xmldata = xmldata : `      <publish_date>2000-12-16</publish_date>`
xmldata = xmldata : `      <description>A former architect battles corporate zombies, an evil sorceress, and her own childhood to become queen of the world.</description>`
xmldata = xmldata : `   </book>`
xmldata = xmldata : `   <book id="bk103">`
xmldata = xmldata : `      <author>Corets, Eva</author>`
xmldata = xmldata : `      <title>Maeve Ascendant</title>`
xmldata = xmldata : `      <genre>Fantasy</genre>`
xmldata = xmldata : `      <price>5.95</price>`
xmldata = xmldata : `      <publish_date>2000-11-17</publish_date>`
xmldata = xmldata : `      <description>After the collapse of a nanotechnology society in England, the young survivors lay the foundation for a new society.</description>`
xmldata = xmldata : `   </book>`
xmldata = xmldata : `</catalog>`


xmlDoc = ObjectCreate("MSXML2.DOMDocument.6.0")
xmlDoc.async = @FALSE
;xmlDoc.load( "C:\TEMP\book.xml" )
xmlDoc.loadxml( xmldata )
;xmlDoc.SetProperty('SelectionLanguage','XPath')

If xmlDoc.parseError.errorCode != 0
   Pause('parseError', xmlDoc.parseError.reason);  ERROR: The following tags were not closed: assembly, file.
Else
   Pause('Contents', xmlDoc.documentElement.xml)

   objNodeList = xmlDoc.getElementsByTagName("title")
   Pause("Node Count", objNodeList.length)

   For i = 0 To objNodeList.length-1
      data = objNodeList.item(i).xml
      Pause(i + 1, data )
   Next
EndIf

objNodeList = 0
XmlDoc = 0
Exit




Article ID:   W18493
Filename:   XML GetElementsByTagName Sample.txt
File Created: 2013:01:03:12:02:22
Last Updated: 2013:01:03:12:02:22