?
Solved

XML Parsing Array Problem

Posted on 2013-01-25
4
Medium Priority
?
264 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
[X]
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
  • 2
  • 2
4 Comments
 
LVL 18

Accepted Solution

by:
zc2 earned 2000 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 does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

Browsing the questions asked to the Experts of this forum, you will be amazed to see how many times people are headaching about monster regular expressions (regex) to select that specific part of some HTML or XML file they want to extract. The examp…
This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
In this video, Percona Director of Solution Engineering Jon Tobin discusses the function and features of Percona Server for MongoDB. How Percona can help Percona can help you determine if Percona Server for MongoDB is the right solution for …
Suggested Courses

770 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