Solved

XML Parsing Issue

Posted on 2013-01-21
7
235 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
How Do You Stack Up Against Your Peers?

With today’s modern enterprise so dependent on digital infrastructures, the impact of major incidents has increased dramatically. Grab the report now to gain insight into how your organization ranks against your peers and learn best-in-class strategies to resolve incidents.

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Nessus Scan 1 72
XML filtering Windows Event Viewer 10 61
Convert Oracle data into XML document 2 69
PHP alternative to file_get_contents('php://input') 4 61
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, …
Many times as a report developer I've been asked to display normalized data such as three rows with values Jack, Joe, and Bob as a single comma-separated string such as 'Jack, Joe, Bob', and vice versa.  Here's how to do it. 
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

839 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