Solved

XML Parsing Issue

Posted on 2013-01-21
7
226 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

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
XML template problem 4 66
How to read XML file attributes... 17 52
Convert Oracle data into XML document 2 59
How do I bind the results to a grid 3 34
Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
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, …
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…

867 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

19 Experts available now in Live!

Get 1:1 Help Now