使用C#asp.net搜索XML文件中的特定项目 [英] To search specific Items in a XML file using C# asp.net

查看:45
本文介绍了使用C#asp.net搜索XML文件中的特定项目的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

<profile type="ptPerson">
  <people>
    <person>
      <domain>http://www.peoplefinders.com</domain>
      <id>5397080</id>
      <name>
        <title></title>
        <firstName>ABRAHAM</firstName>
        <middleName></middleName>
        <lastName>CHARLOTTEAA</lastName>
        <fullName>ABRAHAM CHARLOTTEAA</fullName>
      </name>
      <age>95</age>
      <dob>AV</dob>
      <address>AV</address>
      <phone>855-241-0552</phone>
      <business></business>
      <link>order.asp?1=ABRAHAM;;;;CHARLOTTEAA;;;;;;;;;;;;;;;;;;5397080&amp;2=name&amp;3=people&amp;4=14&amp;5=Abraham;;;;Aaron;;;;;;;;;;;;&amp;from=dcwTest</link>
      <email></email>
      <akas>
        <name>
          <title></title>
          <firstName>ABRAHAM</firstName>
          <middleName></middleName>
          <lastName>AARON</lastName>
          <fullName>ABRAHAM AARON</fullName>
        </name>
      </akas>
      <cities>
        <locale>
          <city>Pompano Beach</city>
          <state>FL</state>
        </locale>
      </cities>
      <relatives>
        <relative>
          <name>
            <title></title>
            <firstName>CHARLOTTE</firstName>
            <middleName>W</middleName>
            <lastName>AARON</lastName>
            <fullName>CHARLOTTE W AARON</fullName>
          </name>
          <id>5397088</id>
          <link>order.asp?1=CHARLOTTE;;W;;AARON;;;;;;;;;;;;;;;;;;5397088&amp;2=name&amp;3=people&amp;4=1&amp;5=Abraham;;;;Aaron;;;;;;;;;;;;&amp;from=dcwTest</link>
        </relative>
      </relatives>
      <key>ABRAHAM CHARLOTTEAA</key>
      <source>dsPeopleFinders</source>
      <itemType>itPerson</itemType>
    </person>
</people>



我想在此xml文件中搜索特定人员的完整详细信息,该人员的名字和姓氏是从网络表单上的文本框传递的.
即在Form1上-> textbox1->名
textbox2->姓氏
textbox3->城市
现在在结果页面上...我将这些值作为querystring ....并且基于这些值,我必须从xml文件中搜索值并将其显示在gridview中.
请指导...
谢谢......
vikas



I want to search for full details of specific persons in this xml file whose first name and last name are passed from textboxes on the webform.
i.e on Form1--> textbox1--> firstname
textbox2 -- > lastname
textbox3--> city
now on the result page...i get these values as querystring.... and based on these values i have to search values from the xml file and display them in the gridview.
pls guide...
Thanks....
vikas

推荐答案

public void fillfromXML(string Code)
        {
            XmlDocument doc = new XmlDocument();
            doc.Load(Server.MapPath(@"XMLFile1.xml"));
            XmlNodeList addlst = doc.SelectNodes("people/person/name/firstName");
            foreach (XmlNode Empcode in addlst)
            {
                //pass textbox value for Code
                if (Empcode.InnerText == Code)
                {
                    //code to get the values and display in gridview.
                }
            }
        }


这篇关于使用C#asp.net搜索XML文件中的特定项目的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆