regarding XPATH expression ....need help...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • tirumalab
    New Member
    • Apr 2007
    • 21

    regarding XPATH expression ....need help...

    if i enter the value in my textbox(edit_mo bileno) i want to search for the matching and i want to read all the xmlelements in that perticular<cust omer></customer> tag... see below for myxml file...


    XmlTextReader xr = new XmlTextReader(@ "D:\Newfolder\t irumala\myxml.x ml");
    while (xr.Read())
    {
    if (xr.Name == "MobileNo")
    {
    if (edit_mobileno. Text.ToString() == xr.ReadString() )
    {
    messagebox.show (" the valuematched");
    }


    XML FILE(myxml.xml)

    - <Registration >
    - <Customer>
    <Fullname>Mr. tirumalareddy</Fullname>
    <HouseNo>1-23-234</HouseNo>
    <Street>whitefi eld</Street>
    <State>karnatak a</State>
    <City>bangalore </City>
    <Zipcode>560066 </Zipcode>
    <PhoneNo>080293 9930</PhoneNo>
    <MobileNo>99860 08230</MobileNo>
    <CheckoutDate >5/3/2007 12:00:00 AM</CheckoutDate>
    <CheckinDate> 4/30/2007 12:00:00 AM</CheckinDate>
    <RoomType>Singl enonAC</RoomType>
    <Amtpayable>150 </Amtpayable>
    <EmailID>tiruma lab@yahoo.com</EmailID>
    </Customer>
    - <Customer>
    <Fullname>Mr. ravithakur</Fullname>
    <HouseNo>1-43-2345</HouseNo>
    <Street>koramon gala</Street>
    <State>karnatak a</State>
    <City>bangalore </City>
    <Zipcode>530066 </Zipcode>
    <PhoneNo>080453 622</PhoneNo>
    <MobileNo>93434 51521</MobileNo>
    <CheckoutDate >5/4/2007 12:00:00 AM</CheckoutDate>
    <CheckinDate> 4/30/2007 12:00:00 AM</CheckinDate>
    <RoomType>Singl eAC</RoomType>
    <Amtpayable>800 </Amtpayable>
    <EmailID>ravik@ yahoo.com</EmailID>
    </Customer>


    Kindly help me.......i am helpless here........
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    Please refer this
    Link

    Comment

    • tirumalab
      New Member
      • Apr 2007
      • 21

      #3
      Thank You shwetha...

      can you plz tell me how to write an Xpathexpression to find out a perticuler monile no in myxml.xml file as shown above....





      Originally posted by shweta123
      Hi,

      Please refer this
      Link

      Comment

      • tirumalab
        New Member
        • Apr 2007
        • 21

        #4
        Can anybody plz help me.. urgent

        How to pass a textbox value in XPATH expression

        XPathDocument xdoc = new XPathDocument(@ "D:\Newfolder\t irumala\myxml.x ml");
        XPathNavigator xnavi = xdoc.CreateNavi gator();
        string name = "Mr. tirumalareddy"; //textBox1.Text.T oString();
        // long mobileNumber = Convert.ToDoubl e(textBox1.Text );// "9986008230 ";//;

        //string selectexpr="Reg istration/Customer[MobileNo=998600 8230]";

        //string xexpr = xnavi.Compile(s electexpr).ToSt ring();

        XPathNodeIterat or xitre = xnavi.Select("R egistration/Customer[Fullname=name]");
        xnavi.MoveToRoo t();
        while (xitre.MoveNext ())
        {
        MessageBox.Show (xitre.Current. Value);
        }



        when entering directly value like Fullname='tirum alareddy' .. It is accepting..
        But while taking that value from textbox.. it is not working..
        kindly seggest me the solution.



        Originally posted by tirumalab
        Thank You shwetha...

        can you plz tell me how to write an Xpathexpression to find out a perticuler monile no in myxml.xml file as shown above....

        Comment

        • tirumalab
          New Member
          • Apr 2007
          • 21

          #5
          regarding XPATH expression ....need help...

          Can anybody plz help me.. urgent

          How to pass a textbox value in XPATH expression

          XPathDocument xdoc = new XPathDocument(@ "D:\Newfolder\t irumala\myxml.x ml");
          XPathNavigator xnavi = xdoc.CreateNavi gator();
          string name = "Mr. tirumalareddy"; //textBox1.Text.T oString();
          // long mobileNumber = Convert.ToDoubl e(textBox1.Text );// "9986008230 ";//;

          //string selectexpr="Reg istration/Customer[MobileNo=998600 8230]";

          //string xexpr = xnavi.Compile(s electexpr).ToSt ring();

          XPathNodeIterat or xitre = xnavi.Select("R egistration/Customer[Fullname=name]");
          xnavi.MoveToRoo t();
          while (xitre.MoveNext ())
          {
          MessageBox.Show (xitre.Current. Value);
          }



          when entering directly value like Fullname='tirum alareddy' .. It is accepting..
          But while taking that value from textbox.. it is not working..
          kindly seggest me the solution.

          Comment

          Working...