I have a xml file with the following elements:
The non-XPATH method:
($qrda.ClinicalDocument.recordTarget.patientRole.telecom | Where {$_.use -eq "HP"}).value
Or (thanks to Tomalak's helpful comment), using the comparison statement format:
($qrda.ClinicalDocument.recordTarget.patientRole.telecom | Where use -eq "HP").value
Use XPath. Assuming that $qrda
is your XML document:
$path = "/ClinicalDocument/recordTarget/patientRole/telecom[@use='HP']"
$telecom = $qrda.SelectSingleNode($path)
since that path is pretty long and overly specific we can trim it down:
$telecom = $qrda.SelectSingleNode("//telecom[@use='HP']")