question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Namespaces not working in a browser

See original GitHub issue

It throws on the second select() in a browser.

On Node.js it works. If a: prefixes are removed it also works in the browser.

const select = xpath.useNamespaces({
  a: 'http://schemas.openxmlformats.org/spreadsheetml/2006/main'
})
const doc = new XMLDOM.DOMParser().parseFromString(xml)
values = select('//a:si', doc)
  // `Error: XPath parse error`
  .map(string => select('.//a:t[not(ancestor::a:rPh)]', string).map(_ => _.textContent).join(''))
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>\r\n<sst xmlns="http://schemas.openxmlformats.org/spreadsheetml/2006/main" count="4" uniqueCount="4"><si><t>One</t></si><si><t>Two</t></si><si><t>Three</t></si><si><t>Four</t></si></sst>

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9

github_iconTop GitHub Comments

1reaction
JLRishecommented, Mar 22, 2018

@catamphetamine Thanks for the update. After re-reading your initial post, I realize that my guess about node name casing was almost definitely wrong because I now noticed that the error you were getting was an XPath parse error, and nothing in the DOM would have caused that kind of error. I guess this will just have to remain a mystery.

0reactions
catamphetaminecommented, Mar 22, 2018

I guess this will just have to remain a mystery.

Agreed )

Read more comments on GitHub >

github_iconTop Results From Across the Web

TS Namespaces - 'is not a function' in browser - Stack Overflow
I am learning typescript, and have tried separating my code into different files. I have a main file structured like this: // calculator.ts ......
Read more >
"Could not fetch Namespaces list." error in browser back. #1863
Go to Traffic tab of some Workload. Click on any of outbound or inbound trace links. In the opened object's page go to...
Read more >
Type or namespace could not be found
I have a solution containg two Visual C# Class Library (.NET Framework) projects using Visual Studio Professional 15.8.9. Project A references project B...
Read more >
XML Namespaces - W3Schools
XML Namespaces provide a method to avoid element name conflicts. Name Conflicts. In XML, element names are defined by the developer. This often...
Read more >
Compiler Error CS0246 | Microsoft Learn
A type or namespace that is used in the program was not found. You might have forgotten to reference (References) the assembly that...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found