XML parsing with many children using ASP/VBscript

I know this is probably simple for many people but I am having a lot of trouble figuring out how to work a complex XML file.

I need to load data from an xml file into a database.
I can handle all the database code but parsing the xml document correctly is the tough part.
I cannot seem to find any information on how to parse beyond a parnet and a child.

Here is a sample of the xml:

- <ORDER>
<TimeDate>11-12-07 15:06:01</TimeDate>
<ProMember>1000</ProMember>
<PODate>10-09-07</PODate>
<PONumber>48079</PONumber>
- <SpecialInstructions>
- <Instruction>
- <![CDATA[ MCS]]>
 </Instruction>
</SpecialInstructions>
- <Terms>
- <![CDATA[ 2% 10TH]]>
 </Terms>
<OrderTotal>30.80</OrderTotal>
- <Detail>
- <Product>
- <![CDATA[ 11114-7]]>
</Product>
<Quantity>10</Quantity>
<Cost>3.08</Cost>
- <Description><![CDATA[ BOX FRAME- 11X14]]>
</Description>
- <Product>
</Detail>
 </ORDER>
- <ORDER>
<TimeDate>11-13-07 12:22:02</TimeDate>
<ProMember>2333</ProMember>
<PODate>10-10-07</PODate>
<PONumber>3465426</PONumber>
- <SpecialInstructions>
- <Instruction>
- <![CDATA[ Welltom]]>
 </Instruction>
</SpecialInstructions>
- <Terms>
- <![CDATA[ 3% 10TH]]>
 </Terms>
<OrderTotal>20.80</OrderTotal>
- <Detail>
- <Product>
- <![CDATA[ 11114-7]]>
</Product>
<Quantity>10</Quantity>
<Cost>2.08</Cost>
- <Description><![CDATA[ Circle FRAME- 8X8]]>
</Description>
- <Product>
</Detail>
 </ORDER>

I have to parse the Order details, Time, Member, PO, Terms and Special instructions and then each product included in the order (there could be hundreds).

I cannot seem to get past just the order details themselves, I cannot seem to get the product details at all.
I am totally stuck.  Can someone shed some light?




- <ORDER>
	<TimeDate>11-12-07 15:06:01</TimeDate> 
	<ProMember>1000</ProMember> 
	<PODate>10-09-07</PODate> 
	<PONumber>48079</PONumber> 
	- <SpecialInstructions>
		- <Instruction>
		- <![CDATA[ MCS]]> 
          </Instruction>
	  </SpecialInstructions>
	- <Terms>
	- <![CDATA[ 2% 10TH]]> 
	  </Terms>
	<OrderTotal>30.80</OrderTotal> 
	- <Detail>
		- <Product>
		- <![CDATA[ 11114-7]]> 
		  </Product>
		  <Quantity>10</Quantity> 
          <Cost>3.08</Cost> 
		  - <Description><![CDATA[ BOX FRAME- 11X14]]>
            </Description>
		- <Product>
	  </Detail>
  </ORDER>
- <ORDER>
	<TimeDate>11-13-07 13:03:01</TimeDate> 
	<ProMember>1233</ProMember> 
	<PODate>10-10-07</PODate> 
	<PONumber>43535</PONumber> 
	- <SpecialInstructions>
		- <Instruction>
		- <![CDATA[ MCS2]]> 
          </Instruction>
	  </SpecialInstructions>
	- <Terms>
	- <![CDATA[ 5% 8TH]]> 
	  </Terms>
	<OrderTotal>20.20</OrderTotal> 
	- <Detail>
		- <Product>
		- <![CDATA[ 11114-7]]> 
		  </Product>
		  <Quantity>10</Quantity> 
          <Cost>2.02</Cost> 
		  - <Description><![CDATA[ RECT FRAME- 8X11]]>
            </Description>
		- <Product>
	  </Detail>
  </ORDER>

Open in new window

LVL 1
gormlyAsked:
Who is Participating?
 
eulacConnect With a Mentor Commented:
ok... my mistake i thought you know reader.name and reader.attributes properties in XML.

anyway you can use the ff link to parse it in asp.
    http://www.w3schools.com/xml/xml_parser.asp
0
 
eulacCommented:
use my template in parsing XML file. this is in c#.

private void Upload()
            {
                  if( ( txtPath.PostedFile != null ) && ( txtPath.PostedFile.ContentLength > 0 ) )
                  {
                        imgProcessing.Visible = true;
                        string fn = System.IO.Path.GetFileName(txtPath.PostedFile.FileName);
                        string SaveLocation = "/RetailPlus/temp/uploaded_" + fn;

                        txtPath.PostedFile.SaveAs(SaveLocation);
                        XmlTextReader reader = new XmlTextReader(SaveLocation);
                        reader.WhitespaceHandling = WhitespaceHandling.None;

                        while (reader.Read())
                        {
                              switch (reader.NodeType)
                              {
                                    case XmlNodeType.Element:
                                          if (reader.Name == "Stock")
                                          {
                                          
                                          }
                                          else if (reader.Name == "Item")
                                          {
                                          }
                                          else if (reader.Name == "Variation" && reader.GetAttribute("VariationCode") != null)
                                          {

                                          }
                                          else if (reader.Name == "VariationMatrix" && reader.GetAttribute("VariationCode") != null)
                                          {
                                          
                                          }
                                          else
                                          {
                                                Label1.Text = "<b>Reader Name:<b>" + reader.Name + "<br>";
                                          }
                                          break;
                                    case XmlNodeType.Text:
                                          Label1.Text = "<b>" + reader.LocalName + ":<b>" + reader.Value + "<br>";
                                          break;
                              }      
                        }
                        reader.Close();
                        
                  }
                  else
                  {
                        Response.Write("Please select a file to upload.");
                  }

            }
0
 
gormlyAuthor Commented:
eulac

I have no idea how that relates to my problem...
I am using vbscript in asp pages and I do not know C#

Unfortunately I cannot see how your code helps in the slightest, I can't even see a way to take that apart and apply it to vbscript.
0
Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

 
gormlyAuthor Commented:
I have looked over the w3schools link before.
It doesn't help.
It does not have much by the way of vbscript examples.

My issue isn't loading an XML or even retriving a set of data, it is getting the subset of data .

Parent
>Child
>>SubChild

In my example it is
Order
>Order Details
>>Multiple Product Details

I cannot seem to figure out how to loop through and get the Multiple Product Details of the Order Details

so my problem is not simply solved by a link explaining (simply) XML.
 It's the extended XML processing I am having a problem with.
I am well versed in google and so far, it's been no help, everything out there is a rehash of the basic xml parsing.
0
 
_Stilgar_Commented:
Consult with the following links:

http://authors.aspalliance.com/das/xmlparse.aspx
http://www.webdevbros.net/2007/07/01/asp-vbscript-rss-readerwriter-class/
http://www.xmlfiles.com/dom/dom_access.asp

These are the basics. You will need to customize those methods to your required use.

Stilgar.
0
 
EGormlyCommented:
This was not abandoned.
The question was not solved.

Giving links to methods or similar situations seems to be gaining much steam on this website unfortunately and in most cases, the links do not help. I didn't need a glorified google search, I needed help.

To that end, the question was not abandoned, it just wasn't answered.
0
 
_Stilgar_Commented:
With all due respect, you can't expect busy people to sit and write functions for you, especially not in 125-points questions. I gave you an excellent direction to go to, would now also appen using XPath to my recommendations, and if you can't go through with the above I'd suggest you ask a more specific question for 125 points, or raise the question's value.

I honestly think you can get what you're looking for from the links I posted above. You can't expect ppl here to do all the work for you.

Stilgar.
0
 
gormlyAuthor Commented:
It is clear I offended both _Stilgar_ and Vee_Mod

I apologize for offending anyone, it wasn't my intention.
_Stilgar_ I appreciate the links you gave they just did not help. When I mentioned a google search, I meant it, they are the same links I came up with when I search before I posted.  They didn't help.

As far as asking for a function to be written for me.. I did NO such thing, I didn't ask for that nor expect it. I am aware of the points to response ratio on EE I have since become a paid member and always set them to 500 for that very reason.


Vee_Mod,  with respect to your opinion, I feel I did not abandon this question but I see that EE has a different definition of abandon and I shouldn't have taken it the way I did. I check back on my open questions often, althought I did not realize there was a "Request Attention" link, thank you for that information.  

There was no malicious intent in my comments and I have nothing but respect for this website and it's volunteers.

Also, to be very, very clear, I did not ask for more than "help".  
Again, I apologize for offending both of you, it wasn't the intent.
0
 
gormlyAuthor Commented:
Partial solution, the basics of XML parsing, this was the first link given so I am awarding point because of this.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.