Solved

XML Parsing Issue

Posted on 2013-01-21
7
229 Views
Last Modified: 2013-01-22
Hello,

I have the following code to parse an XML page (below):

Set xmlDOM = CreateObject("MSXML2.DOMDocument.3.0")
xmlDOM.async = False
xmlDOM.setProperty "ServerHTTPRequest", True
xmlDOM.Load(Filename)
xmlDOM.setProperty "SelectionLanguage", "XPath"

set CountryList = XMLDom.SelectNodes("//result")
            For Each i In CountryList
            
            CountryCode = ""
            CountryDescription = ""
            
            CountryCode = i.SelectSingleNode("//CountryCode").text
          CountryDescription = i.SelectSingleNode("//CountryDescription/element[Language='EN']/Description").text
            
            set RegionList = i.SelectNodes("//Regions")
            
                  for each j in RegionList
                  
                  RegionCode = ""
                  RegionDescription = ""
                  
                  RegionCode = j.SelectSingleNode(".//RegionCode").text
                RegionDescription = j.SelectSingleNode(".//RegionDescription/element[Language='EN']/Description").text

                  SQL = "Insert INTO CountryReference ("
                  SQL = SQL & "CountryCode, CountryDescription, RegionCode, RegionDescription"      
                  SQL = SQL & ") VALUES ('"
                  SQL = SQL & CountryCode & "','" & CountryDescription & "','" & RegionCode & "','" & RegionDescription & "')"
                        
                  response.Write(SQL & "<HR>")
                  response.Flush()
            
                  Next
            
            Next

The XML page I am parsing is attached.

The problem I have is that I am getting the regions, but the country code and description is not changing - as can be seen here: http://www.villasdirect.com/_admin/scripts/LG_Data_Feed_ReferenceRegionsV1.asp

Austria (search for >AT<) has a lot of regions, but if you look, you'll see that they all appear under Andorra.

I'm not sure what I've done wrong but help needed and appreciated!

THANK YOU!

Help
ReferenceRegionsV1.xml
0
Comment
Question by:Nico2011
  • 4
  • 3
7 Comments
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 38801158
probably should be
 i.SelectNodes(".//Regions")

Open in new window

HTH

Ivo Stoykov
0
 

Author Comment

by:Nico2011
ID: 38801172
Thanks Ivo, but the country still remains as Andorra...
0
 
LVL 22

Expert Comment

by:Ivo Stoykov
ID: 38801200
could you paste the xml file?
0
DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

 

Author Comment

by:Nico2011
ID: 38801231
Hi Ivo,

Here's the XML file - thanks very much!
ReferenceRegionsV1.xml
0
 
LVL 22

Accepted Solution

by:
Ivo Stoykov earned 500 total points
ID: 38802010
set CountryList = XMLDom.SelectNodes("//result")

Open in new window

should be
set CountryList = XMLDom.SelectNodes("//Country")

Open in new window

CountryCode = i.SelectSingleNode("//CountryCode").text

Open in new window

should be
CountryCode = i.SelectSingleNode("./CountryCode").text

Open in new window

set RegionList = i.SelectNodes("//Regions")

Open in new window

should be
set RegionList = i.SelectNodes("./Regions")

Open in new window

RegionCode = j.SelectSingleNode(".//RegionCode").text
RegionDescription = j.SelectSingleNode(".//RegionDescription/element[Language='EN']/Description").text

Open in new window

should be
RegionCode = j.SelectSingleNode("./RegionCode").text
RegionDescription = j.SelectSingleNode("./RegionDescription/element[Language='EN']/Description").text

Open in new window


HTH

Ivo Stoykov
0
 

Author Comment

by:Nico2011
ID: 38802091
Thanks Ivo - will check in the morning - on my iPad now...!
0
 

Author Closing Comment

by:Nico2011
ID: 38805117
Thank you Ivo - works perfectly now ;-)
0

Featured Post

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

Question has a verified solution.

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

The Confluence of Individual Knowledge and the Collective Intelligence At this writing (summer 2013) the term API (http://dictionary.reference.com/browse/API?s=t) has made its way into the popular lexicon of the English language.  A few years ago, …
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

813 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now