You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
import{JSDOM}from"jsdom";constxml=`<PARAGRAPH> This is a text, about something, that happened on <DATE ISO="20131117">17.November 2013</DATE> . It is a very important date.</PARAGRAPH>`;constdom=newJSDOM(xml,{contentType: "application/xml"});constdoc=dom.window.document;// 2: XPathResult.STRING_TYPEconstdate=doc.evaluate("PARAGRAPH/DATE/@ISO",doc,null,2,null).stringValue;console.log(date);
I can't seem to be able to get XML Attributes using JSDOM and XPath Syntax on this XML Snippet.
<PARAGRAPH>
This is a text, about something, that happened on
<DATEISO="20131117">17.November 2013</DATE>
. It is a very important date.
</PARAGRAPH>
By my understanding PARAGRAPH/DATE/@ISO is valid XPath Syntax for the Attribute and it's working just fine on sites like Xpather
Expected Result: / Result of Browser DOMParser:"20131117"
Basic info:
Minimal reproduction case
I can't seem to be able to get XML Attributes using JSDOM and XPath Syntax on this XML Snippet.
By my understanding
PARAGRAPH/DATE/@ISO
is valid XPath Syntax for the Attribute and it's working just fine on sites like XpatherExpected Result: / Result of Browser DOMParser:
"20131117"
Actual Result w/ JSDOM:
""
Other non-working approaches
PARAGRAPH//DATE/@ISO
,string(PARAGRAPH/DATE/@ISO)
,XPath.FIRST_ORDERED_NODE_TYPE
The evaluation seems to come back empty.
The text was updated successfully, but these errors were encountered: