If you make the result type a node type, then you can get the innerHTML from the node. For example:
var result = document.evaluate(xpathExpression, document, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null);
alert('Xpath Result:' + result.singleNodeValue.innerHTML);
I have the following Xpath that I can retrieve the StringValue from; however, I need to get the actual inner.HTML value so that I can parse at the new line. How would I go about doing this?
var html = '<table><tbody><tr><td width="33%">SMITH WILLIAM <br>SMITH TOM <br>501 NW 3ND ST<br>CHICAGO IL 60073</td></tr></tbody></table>';
var Xpath = '//table/tbody/tr/td';
var parser = new DOMParser();
var doc = parser.parseFromString(html,'text/html');
result = doc.evaluate(Xpath, doc, null, XPathResult.STRING_TYPE, null);
alert('Xpath Result:' + result.stringValue); //NEED HTML i.e. HTML.Value
SMITH WILLIAM SMITH TOM 501 NW 3ND STCHICAGO IL 60073
SMITH WILLIAM <br>SMITH TOM <br>501 NW 3ND ST<br>CHICAGO IL 60073
For future reference, it’s helpful to make sure the code in your question is enough for someone to run (in this case, I get an error that
Perfecto! Thank you Tim! Greatly appreciate the extra effort. I will be sure to include supporting code going forward.