Overthere
asked on
XML in Classic ASP
I have a question that hopefully someone can answer very quickly. I'm trying to read in an XML file and extract data from it. The following is a portion of the XML and also my code (the file/folder location is correct when I have it displayed):
vfolder = txtFolder.value
vfile = txtFile.value
vlocation = vfolder & vfile
set xdDoc = Server.CreateObject("MSXML 2.DOMDocum ent")
xdDoc.load(vlocation)
for each objItem In xdDoc.selectNodes("Respons e/Trip")
vtype = "T"
vtripid = objItem.selectSingleNode(" id").text
vtripdate = objItem.selectSingleNode(" start_date ").text
vdisplayname = objItem.selectSingleNode(" display_na me").text
vtriplocation = objItem.selectSingleNode(" primary_lo cation").t ext
vprofileref = ojbItem.Attributes.getName dItem("pro file_ref") .value
Response.Write "Type = " & vtype & "<br>"
Response.Write "TripId = " & vtripid & "<br>"
Response.Write "TripDate = " & vtripdate & "<br>"
Response.Write "Display_Name = " & vdisplayname & "<br>"
Response.Write "Location = " & vtriplocation & "<br>"
Response.Write "ProfileRef = " & vprofileref & "<br><br>"
next
I have rearranged this so often, that I'm driving myself crazy and it's probably a very simple fix! I've most likely screwed it up worse than when I started... So any/all assistance is appreciated! My goal is to be able to first read through and document all the TRIPS and then go through again and document all the profiles. So I would like to use a for/next loop.
Here is the XML:
- <Response>
<timestamp>1355152311</tim estamp>
<num_bytes>3240</num_bytes >
- <Trip>
- <TripInvitees>
- <Invitee profile_ref="OjMfu7ahFBno_ TZ966pnFw" >
<is_read_only>false</is_re ad_only>
<is_traveler>false</is_tra veler>
<is_owner>true</is_owner>
</Invitee>
- <Invitee profile_ref="bQBFJxFyGL8D0 RQItvLj5w" >
<is_read_only>false</is_re ad_only>
<is_traveler>true</is_trav eler>
</Invitee>
</TripInvitees>
<id>32960045</id>
<relative_url>/trip/show/i d/32960045 </relative _url>
<start_date>2012-12-30</st art_date>
<end_date>2013-01-06</end_ date>
<display_name>disney</disp lay_name>
<image_url>https://www.tripit.com/images/places/default-plane.png</image_url>
<is_private>true</is_priva te>
<primary_location>Orlando, FL</primary_location>
- <PrimaryLocationAddress>
<address>Orlando, FL</address>
<city>Orlando</city>
<state>FL</state>
<zip>32885</zip>
<country>US</country>
<latitude>28.538335</latit ude>
<longitude>-81.379237</lon gitude>
</PrimaryLocationAddress>
- <TripPurposes>
<purpose_type_code>L</purp ose_type_c ode>
<is_auto_generated>false</ is_auto_ge nerated>
</TripPurposes>
<last_modified>1354851203< /last_modi fied>
</Trip>
- <Profile ref="OjMfu7ahFBno_TZ966pnF w">
<is_client>false</is_clien t>
<is_pro>false</is_pro>
<screen_name>darlene101</s creen_name >
<public_display_name>Darle ne Green</public_display_name >
<profile_url>people/darlen e101</prof ile_url>
<home_city>Ashland, KY</home_city>
</Profile>
- <Profile ref="bQBFJxFyGL8D0RQItvLj5 w">
- <ProfileEmailAddresses>
- <ProfileEmailAddress>
<address>darlenebean@rr.co m</address >
<is_auto_import>false</is_ auto_impor t>
<is_confirmed>true</is_con firmed>
<is_primary>true</is_prima ry>
<is_auto_inbox_eligible>fa lse</is_au to_inbox_e ligible>
</ProfileEmailAddress>
</ProfileEmailAddresses>
<is_client>true</is_client >
<is_pro>false</is_pro>
<screen_name>dbean</screen _name>
<public_display_name>Darle ne Bean</public_display_name>
<profile_url>people/dbean< /profile_u rl>
<home_city>Ashland, KY</home_city>
</Profile>
<page_num>1</page_num>
<page_size>500</page_size>
<max_page>1</max_page>
</Response>
vfolder = txtFolder.value
vfile = txtFile.value
vlocation = vfolder & vfile
set xdDoc = Server.CreateObject("MSXML
xdDoc.load(vlocation)
for each objItem In xdDoc.selectNodes("Respons
vtype = "T"
vtripid = objItem.selectSingleNode("
vtripdate = objItem.selectSingleNode("
vdisplayname = objItem.selectSingleNode("
vtriplocation = objItem.selectSingleNode("
vprofileref = ojbItem.Attributes.getName
Response.Write "Type = " & vtype & "<br>"
Response.Write "TripId = " & vtripid & "<br>"
Response.Write "TripDate = " & vtripdate & "<br>"
Response.Write "Display_Name = " & vdisplayname & "<br>"
Response.Write "Location = " & vtriplocation & "<br>"
Response.Write "ProfileRef = " & vprofileref & "<br><br>"
next
I have rearranged this so often, that I'm driving myself crazy and it's probably a very simple fix! I've most likely screwed it up worse than when I started... So any/all assistance is appreciated! My goal is to be able to first read through and document all the TRIPS and then go through again and document all the profiles. So I would like to use a for/next loop.
Here is the XML:
- <Response>
<timestamp>1355152311</tim
<num_bytes>3240</num_bytes
- <Trip>
- <TripInvitees>
- <Invitee profile_ref="OjMfu7ahFBno_
<is_read_only>false</is_re
<is_traveler>false</is_tra
<is_owner>true</is_owner>
</Invitee>
- <Invitee profile_ref="bQBFJxFyGL8D0
<is_read_only>false</is_re
<is_traveler>true</is_trav
</Invitee>
</TripInvitees>
<id>32960045</id>
<relative_url>/trip/show/i
<start_date>2012-12-30</st
<end_date>2013-01-06</end_
<display_name>disney</disp
<image_url>https://www.tripit.com/images/places/default-plane.png</image_url>
<is_private>true</is_priva
<primary_location>Orlando,
- <PrimaryLocationAddress>
<address>Orlando, FL</address>
<city>Orlando</city>
<state>FL</state>
<zip>32885</zip>
<country>US</country>
<latitude>28.538335</latit
<longitude>-81.379237</lon
</PrimaryLocationAddress>
- <TripPurposes>
<purpose_type_code>L</purp
<is_auto_generated>false</
</TripPurposes>
<last_modified>1354851203<
</Trip>
- <Profile ref="OjMfu7ahFBno_TZ966pnF
<is_client>false</is_clien
<is_pro>false</is_pro>
<screen_name>darlene101</s
<public_display_name>Darle
<profile_url>people/darlen
<home_city>Ashland, KY</home_city>
</Profile>
- <Profile ref="bQBFJxFyGL8D0RQItvLj5
- <ProfileEmailAddresses>
- <ProfileEmailAddress>
<address>darlenebean@rr.co
<is_auto_import>false</is_
<is_confirmed>true</is_con
<is_primary>true</is_prima
<is_auto_inbox_eligible>fa
</ProfileEmailAddress>
</ProfileEmailAddresses>
<is_client>true</is_client
<is_pro>false</is_pro>
<screen_name>dbean</screen
<public_display_name>Darle
<profile_url>people/dbean<
<home_city>Ashland, KY</home_city>
</Profile>
<page_num>1</page_num>
<page_size>500</page_size>
<max_page>1</max_page>
</Response>
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Got it! Thanks to both of you!
You're welcome.
Open in new window
Everything else looks fine, except one typo ( vprofileref = ojbItem.Attributes.getNamedIt