Shiunbird
Shiunbird

Reputation: 87

XML full path parsing in JavaScript

I'm sorry I don't even know the proper names of what I need. I apologize for that.

In PowerShell, I can do the following to specify what data I want to extract from XML:

$participantID in $getParticipantListResponseXml.RESPONSE_TRANS_CONF.ACTION.GET.CONFERENCE.ONGOING_PARTY_LIST.ONGOING_PARTY.PARTY.ID

I can't just do in JavaScript:

getElementsByTagName('ID')

Because 'ID'comes up in more than one place, and I need to specify the exact path. How could I do that?

Upvotes: 0

Views: 61

Answers (1)

sothish
sothish

Reputation: 426

This could help

document.evaluate( expression, document, null, XPathResult.ANY_TYPE, null );

Example

document.evaluate( '//p', document, null, XPathResult.ANY_TYPE, null );

Upvotes: 1

Related Questions