Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Reed XML Nodes With VBScript

Status
Not open for further replies.

emmirodriguez

Programmer
Oct 16, 2015
1
CA
Hi I want to read the ContactActivity node of this XML with VB Script:

<?xml version="1.0"?>
<DataSet xmlns="<diffgr:diffgram xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" xmlns:diffgr="urn:schemas-microsoft-com:xml-diffgram-v1">
<DSContactActivity xmlns="">
<ContactActivity diffgr:id="ContactActivity1" msdata:rowOrder="0" diffgr:hasChanges="inserted">
<MessageID>197337</MessageID>
<ActivityType>10</ActivityType>
<ActivityDate>2015-09-22T15:43:56+00:00</ActivityDate>
<Observation>El contacto ha leído el email "Información sobre su Cuenta de Capitalización Individual en Integración AFAP"</Observation>
<Country>US</Country>
<IP>1123638687</IP>
</ContactActivity>
<ContactActivity diffgr:id="ContactActivity2" msdata:rowOrder="1" diffgr:hasChanges="inserted">
<MessageID>197337</MessageID>
<ActivityType>10</ActivityType>
<ActivityDate>2015-10-05T15:11:39+00:00</ActivityDate>
<Observation>El contacto ha leído el email "Información sobre su Cuenta de Capitalización Individual en Integración AFAP"</Observation>
<Country>US</Country>
<IP>1123638659</IP>
</ContactActivity>
<ContactActivity diffgr:id="ContactActivity3" msdata:rowOrder="2" diffgr:hasChanges="inserted">
<MessageID>197337</MessageID>
<ActivityType>10</ActivityType>
<ActivityDate>2015-10-05T15:11:47+00:00</ActivityDate>
<Observation>El contacto ha leído el email "Información sobre su Cuenta de Capitalización Individual en Integración AFAP"</Observation>
<Country>ES</Country>
<IP>1597921715</IP>
</ContactActivity>
</DSContactActivity>
</diffgr:diffgram>
</DataSet>
 
I would recommend you try using PowerShell instead. It has built in cmdlets for reading XML.

I hope that helps.

Regards,

Mark

No trees were harmed in posting this message, however a significant number of electrons were terribly inconvenienced.

Check out my scripting solutions at
Work SMARTER not HARDER.
 
Something like the following:

Code:
[blue]    Dim myXML 
    Dim Contact
    Dim Datum
    Dim result

    Set myXML = CreateObject("Microsoft.XMLDOM")
    
    myXML.Load "f:\file downloads\test.xml" [green]' your file goes here[/green]

    For Each Contact In myXML.getElementsByTagName("ContactActivity")
		result=""
        For Each Datum In Contact.ChildNodes
            result=result & Datum.tagName & ": " & Datum.Text & vbcrlf
        Next
        wscript.echo result & vbcrlf
    Next[/blue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top