Question

XML parsing with many children using ASP/VBscript

Asked by: gormly

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>

                                  
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
20:
21:
22:
23:
24:
25:
26:
27:
28:
29:
30:
31:
32:
33:
34:
35:
36:
37:
38:
39:
40:
41:
42:
43:
44:
45:
46:
47:
48:
49:
50:

Select allOpen in new window

This Question has been solved and asker verified All Experts Exchange premium technology solutions are available to subscription members.

Subscribe now for full access to Experts Exchange and get

Instant Access to this Solution

  • Plus...
  • 30 Day FREE access, no risk, no obligation
  • Collaborate with the world's top tech experts
  • Unlimited access to our exclusive solution database
  • Never be left without tech help again

Subscribe Now

Asked On
2007-11-19 at 08:38:32ID22970516
Tags

xml

,

vbscript

,

parse

,

asp

Topics

Extensible Markup Language (XML)

,

Active Server Pages (ASP)

Participating Experts
3
Points
125
Comments
12

Trusted by hundreds of thousands everyday for fast, accurate and reliable tech support.

  • "The time we save is the biggest benefit of Experts Exchange to Warner Bros. What could take multiple guys 2 hours or more each to find is accessed in around 15 minutes on Experts Exchange." Mike Kapnisakis, Warner Bros.
  • "Our team likes having a resource that is more secure than just using Google and most experts using this service really know their stuff. It's nice to look here first versus using Google." Dayna Sellner, Lockheed Martin
  • "Anytime that I've been stumped with a problem, 9 out of 10 times Experts Exchange has either the accepted solution or an open discussion of the potential solution to the problem." Kenny Red, eBay Inc.

See what Experts Exchange can do for you.

Got a question?

We've got the answer.

Experts Exchange has been collecting answers to technology questions since 1996…3 million and counting! If you have a question, chances are we already have your answer.

Screenshot of Experts Exchange Knowledgebase

Need individual assistance?

Our experts are ready to help.

If you can't find the exact answer you're looking for, ask our exclusive community of 50,000 experts. You’ll get a personalized answer from a trusted professional.

Screenshot of Experts Exchange Knowledgebase

Want to learn from the best?

Read articles from industry experts.

Thousands of free tech tips, tricks, how-to’s and tutorials are available in our peer reviewed articles section. See for yourself how smart our experts are, no login required.

Screenshot of an Article

Working on a long term project?

Store your work and research.

Save solutions to your questions, answers you’ve discovered through searching plus helpful articles in your personal knowledgebase for easy future access.

Screenshot of Experts Exchange Knowledgebase

Access the answers to your technology questions today.

Subscribe Now

30-day free trial. Register in 60 seconds.

What Makes Experts Exchange Unique?

Members of the expert community talk about why the experience at Experts Exchange is different than what you will find anywhere else.

Trusted by the world's most respected brands.

image of each brand's logo

Faithfully serving IT professionals since 1996.

Experts Exchange Logo

Try it out and discover for yourself.

Subscribe Now

30-day free trial. Register in 60 seconds.

Related Solutions

  1. XML CDATA section displayed using XSL
    I'm sure this question has an easy answer, but I am having trouble with it. I want a CDATA section that is in an XML file to be displayed using XSL. I'm using the MSXML4.0 with XMLDOM, but this shouldn't matter much. A snippet of XML would look like this: <cdata_paragr...
  2. Read CDATA section
    I have XML file with CDATA section. How I can to read text buffer from CDATA in my VC++ programm. (I use the IXMLDOMDocumentPtr) <Element> <![CDATA[abcdef]]> <![CDATA[12345]]> <![CDATA[gfgfgfg]]> </Element>
  3. How to implement CDATA into XML
    Hi, I'm wanting to add some html links and special characters to my imported XML file and know that using CDATA to encapsulate the text is the way to go. Could anyone tell me the correct way to add some CDATA text to the _newstext part of my XML file (see attached sample co...

Free Tech Articles

  1. WARNING: 5 Reasons why you should NEVER fix a computer for free.
    It is in our nature to love the puzzle. We are obsessed. The lot of us. We love puzzles. We love the challenge. We thrive on finding the answer. We hate disarray. It bothers us deep in our soul. W...
  2. SCCM OSD Basic troubleshooting
    SCCM 2007 OSD is a fantastic way to deploy operating systems, however, like most things SCCM issues can sometimes be difficult to resolve due to the sheer volume of logs to sift through and the dispe...
  3. Migrate Small Business Server 2003 to Exchange 2010 and Windows 2008 R2
    This guide is intended to provide step by step instructions on how to migrate from Small Business Server 2003 to Windows 2008 R2 with Exchange 2010. For this migration to work you will need the fo...
  4. Create a Win7 Gadget
    This article shows you how to create a simple "Gadget" -- a sort of mini-application supported by Windows 7 and Vista. Gadgets can be dropped anywhere on the desktop to provide instant information, ...
  5. Outlook continually prompting for username and password
    There have been a lot of questions recently regarding Outlook prompting for a username and password whilst using Exchange 2007. There are a few reasons why this would happen and I will try to cover t...
  6. Backup Exchange 2010 Information Store using Windows Backup
    There seems to be quite a lot of confusion around the ability to backup Exchange 2010 using the built in Windows Backup feature. This stems from the omission of this feature prior to Exchange 2007 s...

Cloud Class Webinars

  1. Avoiding Bugs in Microsoft Access
    Alison Balter takes and in-depth look at avoiding bugs in Access. In this webinar you will learn about using the immediate window to debug your applications, invoking the debugger, using breakpoints to troubleshoot, stepping through code, setting the next statement to execute, ...
  2. Top 10 Best New Features in Visio 2010
    Scott Helmers gives live demonstrations of the top 10 new features in Visio 2010. This webinar will teach you how to create compelling diagrams by adding shapes to the page with a single click, linking the shapes in a diagram to data in Excel (or SQL Server, or SharePoint), ...
  3. IT Consultant Business Secrets Revealed
    Michael Munger, Experts Exchange tech pro and IT consultant, pulls back the curtain on his very successful businesses and answers question on every IT consultant and business owner should know about. He shares secrets on what he did to solve the 5 most common problems in IT, ...
  4. Disaster Recovery and Business Continuity
    Quest CTO, Mike Billon, gives an overview of the steps involved in building a dunamic disaster recovery plan. Through case studies and an examination of software/hardware tooles for monitoring and testing, you'll gain a better understandin of where you are, where you want ...
  5. Organize Your Visio Diagrams with Containers and Lists
    Scott Helmers uses cross functional flowcharts, wireframe diagrams, data graphic legends and seating charts to teach you: how to ustilize all three new structured diagram components in Visio 2010, the best practices for organizeing shapes in previous version of Visio, how to organize ...
  6. How to Us Objects, Properties, Events and Methods in Microsoft Access
    Alison Dalter gives an in-depbth look at objects, properties, events and methods in Microsoft Access. In this webinar you will learn about using the object browser, referring to objects, working with properties and methods, working with object variables, understanding the ...

Join the Community

Give a Little. Get a Lot.

Join the community of experts here and help other tech pros by answering question in your area of expertise. You can earn FREE access to all Experts Exchange's premium features and resources.

Join the Community

Answers

 

by: eulacPosted on 2007-11-19 at 08:44:32ID: 20313535

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.");
                  }

            }

 

by: gormlyPosted on 2007-11-19 at 08:56:06ID: 20313603

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.

 

by: eulacPosted on 2007-11-19 at 09:07:06ID: 20313677

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

 

by: gormlyPosted on 2007-11-19 at 10:24:01ID: 20314204

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.

 

by: _Stilgar_Posted on 2007-12-05 at 09:22:49ID: 20413201

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.

 

by: EGormlyPosted on 2008-12-22 at 05:43:17ID: 23226305

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.

 

by: _Stilgar_Posted on 2008-12-22 at 05:57:16ID: 23226388

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.

 

by: gormlyPosted on 2008-12-23 at 06:58:22ID: 23233928

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.

 

by: gormlyPosted on 2008-12-23 at 07:00:09ID: 31409961

Partial solution, the basics of XML parsing, this was the first link given so I am awarding point because of this.

20120131-EE-VQP-002

3 Ways to Join

30-Day Free Trial

The Experts

98% positive feedback on 31,087 answers since March 2000. angeliii is a Microsoft Most Valuable Professional for his work with MS SQL Server & Develoment.

He has also proven his knowledge of Visual Basic Programming, PHP Scripting and Oracle Databases.

The Experts

97% positive feedback on 10,752 answers since July 2000. lrmoore has more than 18 years experience in the networking industry.

The six-time Mircosoft MVPs specialties include firewalls, virtual private networking, and network management.

Testimonials

"...and excellent source for support... Kind of like having your very own IT dept." Electriciansnet

Testimonials

"I was apprehensive at signing up at first. However... it has already made my life as an IT administrator much easier." JaCrews

Testimonials

"WOW! You guys have great, active, and knowledgeable people on here." moore50

Business Clients

Business Clients

In the Press

"If you’ve got a question... Experts Exchange can supply an answer.”

In the Press

"...an invaluable aid for both IT professionals and those who require tech support."

In the Press

"where IT professionals provide quick answers on just about any topic"

Business Account Plans

Loading Advertisement...