Solved

XML Parsing Array Problem

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Create html table using xsl 8 36
ebay devID, appID, certID, userToken 2 29
ASP server side get value 15 24
JS does not refresh 6 21
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…
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, …
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

809 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