?
Solved

XML Parsing Issue

Posted on 2013-01-21
7
Medium Priority
?
246 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

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 2000 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

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

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

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.
Create a Windows 10 custom Image with custom task bar and custom start menu using XML for deployment.
This video shows how to quickly and easily deploy an email signature for all users in Office 365 and prevent it from being added to replies and forwards. (the resulting signature is applied on the server level in Exchange Online) The email signat…
Screencast - Getting to Know the Pipeline
Suggested Courses
Course of the Month14 days, 16 hours left to enroll

840 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