Solved

XML Parsing Array Problem

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

More Than Just A Video Library

Train for your certification. Learn the latest DevOps tools. Grow your skillset to do better work.

At Linux Academy, we release new training modules every week so you'll always be up to date on the latest tech.

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…
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.
Come and listen to Percona CEO Peter Zaitsev discuss what’s new in Percona open source software, including Percona Server for MySQL (https://www.percona.com/software/mysql-database/percona-server) and MongoDB (https://www.percona.com/software/mongo-…
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …

688 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