I have created this on my localhost webpage and i want have a button and when that button is clicked i want to show the same result in a pdf. I have a couple of answers but it doesn't relate with my issue.
Thanks in advance
using System;
using System.Linq;
using System.Xml;
using System.Xml.Linq;
public class Program
{
public static void Main()
{
string str = @"<?xml version='1.0'?>
<information>
<details>
<id>01</id>
<empname>qwer</empname>
<empid>001</empid>
<dept>Accounts</dept>
<date>2011-01-15 12:21:25</date>
</details>
<details>
<id>02</id>
<empname>jdfklgd</empname>
<empid>002</empid>
<dept>Finance</dept>
<date>2011-01-20 10:21:25</date>
</details>
</information>";
var str1 = XElement.Parse(str);
//Search ID
string searchID = "01";
//Get Result
var result = str1.Elements("details").Where(x => x.Element("id").Value.Equals(searchID)).ToList();
if(result.Count() > 0)
{
//Get Specific element value
string s = result[0].Elements("empname").FirstOrDefault().Value;
Console.WriteLine(s);
}
}
}