Solved

XML Parsing Array Problem

Posted on 2013-01-25
4
247 Views
Last Modified: 2013-01-25
Hello,

I am trying to the data from two nodes... here's my a part of the XML feed:

<PropertiesV1>
  <element>
    <TypeNumber>10</TypeNumber>
    <TypeContents>
      <element>110</element>
    </TypeContents>
  </element>
  <element>
    <TypeNumber>30</TypeNumber>
    <TypeContents>
      <element>385</element>
      <element>393</element>
    </TypeContents>
  </element>
</PropertiesV1>

Open in new window


The feedback I get works for the first <element>, but when I try to get both <elements> from the second <element> node, I only get the first:

10 110,
30 385,

Open in new window


The feedback I should get is:
10 110,
30 385,393,

So I'm not picking up the nodes the right way - here's my code, and I know something is wrong here - I just don't know quite how to do it!

	set Property_Details = itemAttrib.SelectNodes("./PropertiesV1/element")

		For Each i In Property_Details
		Type_Code = ""
		Description_Code = ""
		Type_Code = i.SelectSingleNode("./TypeNumber").text
			set Description_Code_List = i.SelectNodes("./TypeContents")
				for Each j In Description_Code_List
				Description_Code = Description_Code & j.SelectSingleNode("./element").text & ","
				next
		Response.Write(Type_Code & " " & Description_Code & "<HR>")			
		next

Open in new window


Thanks in advance!
0
Comment
Question by:Nico2011
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
zc2 earned 500 total points
ID: 38818908
try to enumerate the TypeContents' children elements, not just TypeContents
    	set Description_Code_List = i.SelectNodes("./TypeContents/element")
		for Each j In Description_Code_List
    		Description_Code = Description_Code & j.text & ","
   		next

Open in new window

0
 

Author Closing Comment

by:Nico2011
ID: 38818950
Thank you!

One thing - the first comma doesn't appear - any ideas...?
0
 
LVL 18

Expert Comment

by:zc2
ID: 38818975
I ran the code and here is the output i got:
10 110,<HR>
30 385,393,<HR>
What comma did you mean?
0
 

Author Comment

by:Nico2011
ID: 38818995
hmm - the one between the 385 and the 393... doesn't show - I get a space instead.

Not to worry, I can use the space to separate the array.

Thanks and have a good weekend.

Best wishes/Nico
0

Featured Post

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

I recently decide that I needed a way to make my pages scream on the net.   While searching around how I can accomplish this I stumbled across a great article that stated "minimize the server requests." I got to thinking, hey, I use more than one…
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.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

706 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

20 Experts available now in Live!

Get 1:1 Help Now