Read XML Value using LINQToXML in C#.Net

Posted by Naraayanan under C# on 3/19/2013 | Points: 10 | Views : 1122 | Status : [Member] | Replies : 2
Hi All,
My Application stores the value into XML Document. This is my XML structure..So Please let me know how can i get XML value using LINQ in VS2008.

XML Structure:
<?xml version="1.0" encoding="utf-8"?>
<TestReport>
<UnitTest>
<WindowsApplicaiton>1</WindowsApplicaiton>
<WebApplicaiton>0</WebApplicaiton></UnitTest>
</TestReport>
.

My Query
Retrieve WebApplication value via LINQToXML.
Add WebApplication value via LINQToXML.


Regards,
Lakshmi Naraayanan.S
http://dotnettechrocks.blogspot.in/
http://abaprocker.blogspot.com/



Responses

Posted by: Vforvijay on: 3/19/2013 [Member] Starter | Points: 25

Up
0
Down
Hi..
Refer the belo link to use linw in XML
http://www.dotnetcode.in/2013/02/how-to-use-linq-query-in-xml-data-souce.html


Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sakthi.Singaravel on: 3/20/2013 [Member] Silver | Points: 25

Up
0
Down
 XDocument inXML = new XDocument();

inXML = XDocument.Load(_File_path_);
foreach (XElement WinAppEle in from ele in inXML.Root.Descendants("UnitTest").ToList() where ele.Element("WindowsApplicaiton") != null select ele)
{
String valVar = WinAppEle .Element("WindowsApplicaiton").Value
//Do ur operations here
}


Regards,
Singaravel M

Naraayanan, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response