Solved

Parsing XML VBScript

Posted on 2013-01-07
2
567 Views
Last Modified: 2013-01-08
Hello,

I have an XML file which I'm trying to parse.  I get most of the data with no issues, but there is a sub array for images, which has 3 nodes, but my code isn't seperating the nodes, so I'm getting all the data in one long string - I need it seperated so I can add it to my DB...

The first part of the XML file is:
<?xml version="1.0" encoding="utf-8"?>
<result>
<HouseCode>AT-1010-04</HouseCode>
<Updated>2013-01-06T10:55:59-08:00</Updated>
<BasicInformationV3>
  <Name>Studio Wien Zentrum</Name>
  <MaxNumberOfPersons>2</MaxNumberOfPersons>
  <ExceedNumberOfBabies>0</ExceedNumberOfBabies>
  <NumberOfPets>3</NumberOfPets>
  <NumberOfStars>3</NumberOfStars>
  <DimensionM2>25</DimensionM2>
  <ZipPostalCode>1010</ZipPostalCode>
  <Country>AT</Country>
  <Region>NIE</Region>
  <CreationDate>2010-02-22</CreationDate>
  <WGS84Longitude>16.383728</WGS84Longitude>
  <WGS84Latitude>48.211055</WGS84Latitude>
  <OptionsAllowed>No</OptionsAllowed>
  <HolidayPark>at-1010-001</HolidayPark>
  <EnqeCount>6</EnqeCount>
  <EnqePoints>54</EnqePoints>
  <NumberOfBedrooms>0</NumberOfBedrooms>
  <NumberOfBathrooms>1</NumberOfBathrooms>
  <SkiArea/>
  <Brands>
    <element>
      <SequenceNumber>1</SequenceNumber>
      <Brand>BV</Brand>
    </element>
  </Brands>
</BasicInformationV3>
<MediaV1>
  <Photos>
    <Photo>
      <Tag>ExteriorSummer</Tag>
      <Height>500</Height>
      <URL>media.leisure-ict.net/photo/web/500/83583_lsr_20101213106909640392.jpg</URL>
    </Photo>
    <Photo>
      <Tag>ExteriorSummer</Tag>
      <Height>500</Height>
      <URL>media.leisure-ict.net/photo/web/500/83583_lsr_2010110252638872804.jpg</URL>
    </Photo>

Open in new window


and my code,which is within another array (of all the properties) is:
set images_list = itemAttrib.SelectNodes("MediaV1/*[starts-with(name(),'Photo')]")
    For Each i In images_list
	z = z + 1
    image = i.text
    	if image <> "" then
	imagename = right(image, (len(image) - len("http://media.leisure-ict.net/photo/web/")))
	response.Write(imagename & "<BR>")
    	end if
	response.Flush()
    next

Open in new window


And the output I get is:

t/photo/web/500/83583_lsr_20101213106909640392.jpg ExteriorSummer 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252638872804.jpg ExteriorSummer 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252568593389.jpg HallReception 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252815864325.jpg LivingRoom 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252896152910.jpg LivingRoom 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252881510637.jpg LivingRoom 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252850841576.jpg Kitchen 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252865548629.jpg Kitchen 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252914303597.jpg ParkFacilities 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252739056371.jpg ParkFacilities 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252765821198.jpg ParkFacilities 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252582697238.jpg ParkFacilities 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252779065199.jpg AreaSummer1KM 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252517689956.jpg AreaSummer1KM 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252697644269.jpg AreaSummer1KM 500 media.leisure-ict.net/photo/web/500/83583_lsr_2010110252601105859.jpg

Open in new window


It's also missing part of the first image filename, bu I do also want to be able t grab the description of each image, which is in the data above, but all bunched up!

Help appreciated - thanks!
0
Comment
Question by:Nico2011
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 20

Accepted Solution

by:
ltlbearand3 earned 500 total points
ID: 38753599
I don't know that I have enough detail, but will take a shot.  When you say you want this broken out into the different nodes for you database, do you just want this in additional variables?  Since I don't have all your code, I am not sure what you are doing with the Z Variable so I left it.  I also don't understand why you do you node select with Start with Photo as you have a node name Photos and one named Photo.  I would recommend a more clear search to find the node you expect.  The command that strips out the first part of the URL has more information that what is in your node value.  I am guessing you are just wanting the file name and I have tried to adjust for that.

Maybe try something like this:

set images_list = itemAttrib.SelectNodes("//Photo")

For Each i In images_list
	z = z + 1
	If Not i.SelectSingleNode(".//Tag") is nothing Then
		strTag = i.SelectSingleNode(".//Tag").text
		response.Write(strTag & "<BR>")
	End if
	If Not i.SelectSingleNode(".//Height") is nothing Then
		strHeight = i.SelectSingleNode(".//Height").text
		response.Write(strHeight & "<BR>")
	End if
	If Not i.SelectSingleNode(".//URL") is nothing Then
		strUrl = i.SelectSingleNode(".//URL").text
		If left(strUrl, 4) = "Http" Then
			strurl = right(strUrl, len(strUrl) - len("http://media.leisure-ict.net/photo/web/" & strHeight & "/"))
		Else
			strurl = right(strUrl, len(strUrl) - len("media.leisure-ict.net/photo/web/" & strHeight & "/"))
		End if
		response.Write(strTag & "<BR>")
	End if
	response.Flush()
next

Open in new window


-Bear
0
 

Author Closing Comment

by:Nico2011
ID: 38754156
That is PRECISELY what I needed - thank you so much Bear - works perfectly!
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
modifying VBScript to VBA 17 89
MS Access VBA How To Properly Set Up A multipart/related HTTP Request 13 141
xml with php question 5 53
Selenium and Xpath 4 67
This script will sweep a range of IP addresses (class c only, 255.255.255.0) and report to a log the version of office installed. What it does: 1.)      Creates log file in the directory the script is run from (if it doesn't already exist) 2.)      Sweep…
Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…
Suggested Courses

732 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question