Page 1 of 1

Using XPath toolbar with HTML5 in v.22

Posted: Mon Feb 17, 2020 6:05 pm
by dsewell
According to the "What's New" information for oXygen 22.0, "You can use the XPath Toolbar or XPath Builder View to quickly query HTML documents using XPath expressions." I tried to test this out on a minimal HTML 5 file:

Code: Select all

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>Title</title>
    <link rel="stylesheet" href="style.css">
    <script src="script.js"></script>
  </head>
  <body>
    <div>
      <p>This is a very simple test of <a href="https://www.oxygenxml.com">oXygen</a> support for XPath in HTML 5</p>
    </div>
  </body>
</html>
This is valid HTML 5 and oXygen's Validate function reports that it is valid. But if I try to search on any XPath, like //p, I get the error message:
XPath failed due to: The element type "link" must be terminated by the matching end-tag "</link>"
Am I doing something wrong? I thought the idea was that XPath would be possible on valid HTML5 even if it is not well-formed XML?

Re: Using XPath toolbar with HTML5 in v.22

Posted: Tue Feb 18, 2020 9:54 am
by tavy
Hello,

Thanks for your feedback.
Unfortunately I cannot reproduce de problem. I tested with <oXygen/> XML Editor 22.0, build 2020021016, I created a new HTML file and pasted the content you provided, then run the XPath //p. The XPath result was returned correctly for the HTML5 document.
Maybe you associated the HTML files with the XHTML editor. You can verify this in the Preferences dialog, go to Options->Preferences->File Types options page, and search for "html" extension. In case the extension is associated with the "XHTML Editor", change it to "HTML Editor". Then reopen the file and run the XPath expression again.

Best Regards,
Octavian

Re: Using XPath toolbar with HTML5 in v.22

Posted: Tue Feb 18, 2020 4:30 pm
by dsewell
Yes, your guess was correct. I had changed the file type preference at some time in the past and forgot about that. After changing the preference as suggested, XPath works. Thanks!