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);
}

Related Query

More Query from same tag