使用C#asp.net搜索XML文件中的特定项目 [英] To search specific Items in a XML file using C# asp.net
问题描述
<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&2=name&3=people&4=14&5=Abraham;;;;Aaron;;;;;;;;;;;;&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&2=name&3=people&4=1&5=Abraham;;;;Aaron;;;;;;;;;;;;&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屋!