Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

XML Parsing Array Problem

Posted on 2013-01-25
4
254 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

How our DevOps Teams Maximize Uptime

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

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
microsoft access - xml 10 73
FileUp - Classic ASP 5 19
Call a function within the ASP code 4 19
CREATE DATABASE 3 28
Hello, all! I just recently started using Microsoft's IIS 7.5 within Windows 7, as I just downloaded and installed the 90 day trial of Windows 7. (Got to love Microsoft for allowing 90 days) The main reason for downloading and testing Windows 7 is t…
Have you ever needed to get an ASP script to wait for a while? I have, just to let something else happen. Or in my case, to allow other stuff to happen while I was murdering my MySQL database with an update. The Original Issue This was written…
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

792 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