How to get nodes xpath
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 68
- Joined: Mon Jul 04, 2022 8:42 am
How to get nodes xpath
Hi Team,
Below is the example where i need xpath of para node including its parents.
Ex ;
<footnote>
<footnote.body>
<para> Testing the xpath
</para>
</footnote.body>
</footnote>
in the above xml say i have clicked in para so now i need the path where my cursor placed. Below is the result which i need. Please let me know how to achieve this using javasript.
//footnote/footnote.body/para
Using below code i am getting tag name where my cursor placed like para but i want whole parent xpath as well.
let selection = jaEditor.getSelectionManager().getSelection();
let tagName = selection.getNodeAtSelection().getNodeName();
Below is the example where i need xpath of para node including its parents.
Ex ;
<footnote>
<footnote.body>
<para> Testing the xpath
</para>
</footnote.body>
</footnote>
in the above xml say i have clicked in para so now i need the path where my cursor placed. Below is the result which i need. Please let me know how to achieve this using javasript.
//footnote/footnote.body/para
Using below code i am getting tag name where my cursor placed like para but i want whole parent xpath as well.
let selection = jaEditor.getSelectionManager().getSelection();
let tagName = selection.getNodeAtSelection().getNodeName();
-
- Site Admin
- Posts: 172
- Joined: Tue Mar 20, 2018 5:28 pm
Re: How to get nodes xpath
Post by Bogdan Dumitru »
Hello Shilpa,
By "but i want whole parent xpath as well" do you mean that you want to access the parent nodes of the node at caret?
If yes, note that you can use the "parentNode" property like this:
See the Document, Element and Node interfaces from our JS API.
By "but i want whole parent xpath as well" do you mean that you want to access the parent nodes of the node at caret?
If yes, note that you can use the "parentNode" property like this:
Code: Select all
var nodeAtSelection = editor.getSelectionManager().getSelection().getNodeAtSelection();
var parentTagName = nodeAtSelection.parentNode.tagName;
Bogdan Dumitru
http://www.oxygenxml.com
http://www.oxygenxml.com
Jump to
- Oxygen XML Editor/Author/Developer
- ↳ Feature Request
- ↳ Common Problems
- ↳ DITA (Editing and Publishing DITA Content)
- ↳ SDK-API, Frameworks - Document Types
- ↳ DocBook
- ↳ TEI
- ↳ XHTML
- ↳ Other Issues
- Oxygen XML Web Author
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Content Fusion
- ↳ Feature Request
- ↳ Common Problems
- Oxygen JSON Editor
- ↳ Feature Request
- ↳ Common Problems
- Oxygen PDF Chemistry
- ↳ Feature Request
- ↳ Common Problems
- Oxygen Feedback
- ↳ Feature Request
- ↳ Common Problems
- Oxygen XML WebHelp
- ↳ Feature Request
- ↳ Common Problems
- XML
- ↳ General XML Questions
- ↳ XSLT and FOP
- ↳ XML Schemas
- ↳ XQuery
- NVDL
- ↳ General NVDL Issues
- ↳ oNVDL Related Issues
- XML Services Market
- ↳ Offer a Service