score:2
Accepted answer
i corrected your first attempt (linq). it returns first <pname type="patient">
from xml in question.
ienumerable<xelement> tests =
from el in root.element("plist").elements("pname")
let c = el.descendants("classification")
where c.where(x => x.attribute("classification").value == "paymenttype"
&& x.attribute("category").value == "wallet").any()
select el;
then you can iterate tests
and extract what you want.
foreach (var el in tests)
{
console.writeline(
el.element("properties")
.element("pname")
.attribute("title")
.value);
}
i also corrected your second attempt (xpath). it will return title value of <pname title="joe beom" pid="1234">
.
var query = @"//pname[details/classification[@classification='paymenttype' and @category='wallet']]/@title";
foreach (xmlnode n in docs.selectnodes(query))
{
console.writeline(n.value);
}
Source: stackoverflow.com
Related Query
- Read multiple nodes based on Condition
- how to get child single records based on multiple condition having multiple child nodes c# linq or xpath
- How can i copy data table records of different field name based on mapping list evaluating condition on source data table?
- Delete records with multiple ids based on condition
- How to do condition statement in LINQ based on code variables?
- linq query to get multiple datatable from dataset based on some condition
- How to merge multiple lists based on a condition using LINQ
- How to write C# LINQ code to select based on condition
- Replace a list item value with another list item value based on multiple condition
- Select multiple records based on list of Id's with linq
- Remove item from list based on condition
- LINQ: differences between single Where with multiple conditions and consecutive Wheres with single condition
- How do I remove items from generic list, based on multiple conditions and using linq
- Remove duplicates from list based on multiple fields or columns
- Does this LINQ code perform multiple lookups on the original data?
- How to find duplicate items based on multiple values using LINQ?
- Order by descending based on condition
- Split a collection into parts based on condition with LINQ?
- How to reuse a linq expression for 'Where' when using multiple source tables
- Remove Duplicate item from list based on condition
- Split collection into objects based on condition and occurrence
- LINQ Source Code Available
- how to take 100 records from linq query based on a condition
- multiple orderby in this linq code
- Read all XML child nodes of each specific node
- Delete multiple XML nodes in C# using Linq
- How to store and lookup data, based on multiple xml attributes?
- LINQ query on an object list to get distribution based on multiple fields
- .NET 4 Code Contracts: "requires unproven: source != null"
- LInq left join with multiple condition in on clause
More Query from same tag
- This LINQ statement crashes if one of the Properties is NULL. How can I fix this?
- Passing different values to the SELECT NEW part of a LINQ query
- Retrieving specific elements from an XDocument based on a list
- Performing LINQ on full collection of rows in SSIS?
- Fill missing weeks in linq result to 0
- Creating a map from property names to types with that property
- Can't call the Elements() method for System.Xml.Linq in Webmatrix site
- iterate through two lists
- (Linq)Dictionaries: Except not returning a Dictionary
- show distinct item in a dropdownlistfor in mvc
- Left Join 2 tables with main table using LINQ
- Updating list with linq instead of for each
- Show vertical model list to horizontly for each date like Attendace register
- processing Xnode with Linq efficiently
- Get an Array by selection of a block from xml-File
- C# Entity Framework - Sort View when reading from it
- How to pivot rows for an editable grid?
- Most efficient way to make duplicates unique in collection
- DefaultIfEmpty() doesn't work
- LINQ: overriding a column data with another table's data using FK relationship
- How to concatenate multiple rows list with same value into single row
- Check if DB already have a DateTime equals to the one passed in the form
- How to null check c# 7 tuple in LINQ query?
- How to write this in C# Linq
- Remove duplicate items from list if certain properties match and get the top item based on some ordering
- How to store into DB RadioButtonList
- Building Expression Trees
- Making a list distinct in C#
- The entity or complex type cannot be constructed in a LINQ to Entities query - using lambda expression
- LINQ Conditional Where Clauses not working