USING XML IN C#.NET

  • Thread starter ATLANTA PATNAIK via DotNetMonster.com
  • Start date
A

ATLANTA PATNAIK via DotNetMonster.com

Hi,
I am using the below code to search GATE=1 from the xml file but not
getting the output.How to do it?I want to display the contents of GATE=1
in my console application.How to query that particular gate in c#.net?





XPathDocument doc = new XPathDocument("C:\\gates.xml");
XPathNavigator nav = doc.CreateNavigator();
XPathNodeIterator iterator = nav.Select("/ITPL/GATE/@NAME='1'");
while (iterator.MoveNext())
{
Console.WriteLine(iterator.Current.Name);
--------------------------------------------------------------------
<ITPL>
<GATE NAME='2'>
<Slot sno='5'>slot no=5, type=4,VACANT</Slot>
<Slot sno='6'>slot no=6, type=4,VACANT</Slot>
<Slot sno='7'>slot no=7, type=2,VACANT</Slot>
<Slot sno='8'>slot no=8, type=4,VACANT</Slot>
</GATE>
<GATE NAME='1'>
<Slot sno='1'>slot no=1, type=4,VACANT</Slot>
<Slot sno='2'>slot no=2, type=2,VACANT</Slot>
<Slot sno='3'>slot no=3, type=4,VACANT</Slot>
<Slot sno='4'>slot no=4, type=2,VACANT</Slot>
</GATE>
<GATE NAME='3'>
<Slot sno='9'>slot no=10, type=2,VACANT</Slot>
<Slot sno='10'>slot no=11, type=2,VACANT</Slot>
<Slot sno='11'>slot no=12, type=2,VACANT</Slot>
<Slot sno='12'>slot no=13, type=4,VACANT</Slot>
</GATE>
</ITPL>
 
A

ATLANTA PATNAIK via DotNetMonster.com

Thanks.
How to insert further child nodes within a particular slot say slot=2,
and also delete a particular entry under a slot in c#.net.All manipulations
to be done in the same file.
 
A

ATLANTA PATNAIK via DotNetMonster.com

Hi,
Within <slot sno=4>contents</slot> i want to enter further tags say,
<vehicle name="Alto" vno="G565678">Contents</vehicle>.How do i add this tag
and also tell how to delete it when required.
Further i want to query the following:
1)the no of slots having sno=2/4 at a instant?
2)the no. of slot having vno="G565678"?
3)the no. of slots having name="Alto"?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top