Continually Improving.... let us know how support@devdiamond.net Sign in | Sign up
home articles news blog forum  

 
 


 
Skip Navigation LinksHome > Article > Parse XML document with loop statement using ASP.Net
Parse XML document with loop statement using ASP.Net
Abstract :
In this article I will show you how to parse xml document with loop statement, using ASP.Net, VB.Net

Views : 11198
Published : Saturday, October 30, 2004
By
HyperLink

Avarage Rating :
Page Page 1 of 3

View Demo
Click here

Introduction
Although there are several methods to parse an XML Document automatically using for example XSL, or by loading it to a Datagrid and many other easy and useful ways, I found that it's also useful sometimes to parse XML document “Manually”, by looping through it.

Looping through the XML document gives you the ability to programmatically add condition clause, and filtering

For example you can add a If…then…end if statement, and do different kind of conditions easily with your everyday programming techniques, using XSL for example, you have to first master this language, also on some conditions you can't depend on XSL to parse your XML document.

Details

We will parse the following XML document on this article

Hotels.xml

<? xml version="1.0" encoding="ISO-8859-1" ?>
< Data >
< AvailableInventory >
< HotelInventory >
< BlockID > 100003501 </ BlockID >
< HotelName HotelId =" 101651 "> Marriot </ HotelName >
< RoomName RoomTypeID =" 1 "> Single </ RoomName >
< RoomRate > 60.0 </ RoomRate >
< RoomsAvailable > 10 </ RoomsAvailable >
</ HotelInventory >
< HotelInventory >
< BlockID > 100003502 </ BlockID >
< HotelName HotelId =" 101652 "> Hilton </ HotelName >
< RoomName RoomTypeID =" 2 "> Double </ RoomName >
< RoomRate > 60.0 </ RoomRate >
< RoomsAvailable > 10 </ RoomsAvailable >
</ HotelInventory >
……………………………..
</ AvailableInventory >
</ Data >

The result after parsing will look like the following

BlockID Hotel Name Room Type Room Rate Rooms Avail.
100003502 Mariot Double 60.0 10
100003506 Hilton Double 60.0 10
100003510 Intercontinental Double 60.0 10


About Author

        Yasir Send Feedback
        Yasir is a .NET expert, with over 5 years experience in Microsoft Technologies, 8 years overall programming experience, he is the owner, founder & primary contributor of Minwar.com, and he also works as IT Director in the hospitality industry.