Thursday, January 3, 2013

Select an element from xml file using where clause

Here is the sample xml file
<?xml version="1.0" encoding="utf-8" ?>
<urls>
<url keyword="RA">http://google.com </url>
<url keyword="NC">http://google.com </url>
</urls>

Here is the sample code
XDocument doc=XDocument.Load(Server.MapPath("~/urllist.xml"));
var url = (from ur in doc.Descendants("url")
where ur.Attribute("keyword").Value=="RA"
select ur.Value).ToList();

No comments:

Post a Comment

What is DaemonSet in Kubernetes

 A DaemonSet is a type of controller object that ensures that a specific pod runs on each node in the cluster. DaemonSets are useful for dep...