S
S
Svyatoslav Khusamov2017-02-14 19:44:51
JavaScript
Svyatoslav Khusamov, 2017-02-14 19:44:51

How to do without NS prefixes in XPath query?

I'm using the browser's window.DOMParser to parse an XML document

if (window.DOMParser) {
                xmlDoc = (new DOMParser()).parseFromString(xmlString, "application/xml");

Document with prefixes, here is an example:
<Debtor xsi:type="ns1:Individual" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
                  <ns1:PartyId>271229</ns1:PartyId>
                  <ns1:RegistrationAddress>
                     <ns1:City>Москва</ns1:City>
                     <ns1:Street>Зеленоград</ns1:Street>

Accordingly, I need to make a request
Debtor/ns1:RegistrationAddress/ns1:City
. With prefixes, the request passes normally.
How can I do without prefixes?
To successfully make such requests:
Debtor/RegistrationAddress/City
This is necessary because a document comes from the server in which the prefixes are constantly changing.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question