Home > Mobile >  How can I add a namespace when I use XPath using $x function in Google Chrome?
How can I add a namespace when I use XPath using $x function in Google Chrome?

Time:10-03

I usually use $x() function on Google Chrome development console. However, when XML file has a namespace the query does not work. I could not find any way to add the namespace. I was wondering if I am missing something or is a missing feature.

CodePudding user response:

I don't know if there is a way to include namespaces in the function, but it's possible to (try to) avoid them altogether by using local-name().

For example, if your element is (picked randomly for an EDGAR filing):

<edgar:companyName>Federal Bank of Boston</edgar:companyName>

This expression

$x('//*[local-name()="companyName"]')

should select it.

  • Related