parsing xml doc for record count

  • Hey, I was just tasked with getting counts (patient, record) from an xml document.  Is there code out there that will parse an xml doc for counts??  I am stumped....thank you anybody who can help!! 


    Thank you!!,

    Angelindiego

  • Depending on what environment you're in (DTS, SQL 2005, .Net etc) here is a simple vbscript that will load your document and count the numbers of elements you need. Just change the xpath that you want to count. This example will count the total number of patient elements and record elements whereever they are in the document.

    Option Explicit

    Dim xmlDoc

    Dim nodes

    Dim lPatientCount

    Dim lRecordCount

    Set xmlDoc = CreateObject("MSXML2.DOMDocument")

    If xmlDoc.Load("C:\Temp\DataFile.xml") Then

    Set nodes = xmlDoc.SelectNodes("//patient")

    lPatientCount = nodes.length

    Set nodes = xmlDoc.SelectNodes("//record")

    lRecordCount = nodes.length

    End If

    Set nodes = Nothing

    Set xmlDoc = Nothing

  • I will try this!!  Thank you so much!!!!!!!!!


    Thank you!!,

    Angelindiego

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply