Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

extract data from xml 1

Status
Not open for further replies.

DotNetGnat

Programmer
Mar 10, 2005
5,548
IN
Guys,

Need some help on parsing xml file.

Below is the line I have in my code:
XmlNodeList xmlnode = xmldoc.GetElementsByTagName("G_NEW_DATE");

and the outerxml that I get looks like below for xmlnode.OuterXml

Code:
<G_NEW_DATE>
<DAY>THURSDAY</DAY>
<LIST_G_CAT>
<G_CAT>
<1MONTH>100</1MONTH>
<2MONTH>200</2MONTH>
<3MONTH>200</3MONTH>
</G_CAT>
</LIST_G_CAT>
<NEW_DATE>04-01-2010</NEW_DATE>
</G_NEW_DATE>

inside the loop for(int i = 0; i < xmlnode.Count; i++){}

I need to check if the NEW_DATE is today's date and grab the appropriate 1 month or 2 month or 3 month value into a variable based on the input month number.

Any suggestions...

Thanks

-DNG
 
I think what you need is something like this ...

First get the date
Code:
XmlNode nd = xDoc.SelectNode("//G_NEW_DATE/NEW_DATE")

This will return the node, so just use toString() to get the value and compare. Once you have that and checked it use the same method to get the day/month/year

Hope this helps.

Patrick
 
Thanks Patrick.

There is no method called SelectNode.

There are SelectNodes and SelectSingleNode methods that I am looking into.

-DNG
 
Yes, I should have fixed that, apologies, it's SelectSingleNode you sould use.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top