I am new to using LINQ. I would like to use LINQ to retrieve a certain value to given string.I have a XML document (files.xml) that contains below formatting.
<?xml version="1.0" encoding="utf-8" ?>
<DocumentMappings>
<DocumtentCategory>
<CategoryId>001</CategoryId>
<CategoryName>Checksheet and Lists</CategoryName>
<DestinationDocumentLibrary>CheckList and Lists</DestinationDocumentLibrary>
<Multiple>false</Multiple>
</DocumtentCategory>
<DocumtentCategory>
<CategoryId>011</CategoryId>
<CategoryName>Product Information</CategoryName>
<DestinationDocumentLibrary>Product Information</DestinationDocumentLibrary>
<Multiple>true</Multiple>
</DocumtentCategory>
</DocumentMappings>
Question
How do I retreive the value of “DestinationDocumentLibrary” as string for a “CategoryName” of “Checksheet and Lists” using LINQ.
In above example “Checksheet and Lists” is passed as a parameter (string) and will be dynamically passed to the LINQ query.
Hope the question is clear and many thanks in advance.
Give this a try:
xDoc is an XDocument containing your xml.