Archived Forum Post

Index of archived forum posts

Question:

XML Parsing

Sep 25 '14 at 11:53

I am using an ASP page to accept job posts to my site and I'm having a devil of a time retrieving values from the XML. Could someone help me with some sample code to get the values of:

The "UserID" then iterate through each "Job" and get the values of the property "Action", get the "JobTitle" then "ContactName"? Here is the XML:

<jobs xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <userid>5555555</userid> <job action="ADD"> <jobtitle></jobtitle> <jobcontactinformation> <contactname></contactname> </jobcontactinformation> </job> <job action="DELETE"> <jobtitle></jobtitle> <jobcontactinformation> <contactname></contactname> </jobcontactinformation> </job> </jobs>

Thanks!


Answer

XML is case-sensitive. The tag "Job" is not the same as "job". This is not a Chilkat-imposed thing -- it is the XML standard.


Answer

I just did this as a little VBS script to test but here is what I have so far looking at the documentation and samples but then I get lost. Any help would be appreciated:

set xml = CreateObject("Chilkat_9_5_0.Xml")

success = xml.LoadXmlFile("C:Chilkatgood.xml")

If (success <> 1) Then

MsgBox "Load Failure"

Else

MsgBox "Load Success"

End If

numWithTag = xml.NumChildrenHavingTag("Job") MsgBox numWithTag

If (numWithTag > 0) Then

For i = 0 To numWithTag - 1

Next

End If

set xml = Nothing


Answer

Hmmmmm. That was strange that that happened. The XML that I copied from had the uppercase "Job" vs. "job". Something happened in the paste... Anyway, yes, it should be xml.NumChildrenHavingTag("job") in this case. Any idea how I:

Get "userid" then iterate through each "job" and get the values of the property "action", get the "jobtitle" then "contactname"?

Thanks!


Answer

This should help

http://example-code.com/vb6/xml_iter_childWithTag.asp