How can we get previous and next sibling nodes
Having trouble installing Oxygen? Got a bug to report? Post it all here.
-
- Posts: 93
- Joined: Mon Aug 08, 2022 2:32 pm
How can we get previous and next sibling nodes
Post by SmitaPatil »
Hi Team,
Can you please tell how can we get previous and next sibling of current selected node?
We you see in below screenshot we have some nodes in document, suppose currently we have access to node which has content pub target.
Can we get the next sibling node(which has content abc) and previous sibling node(which has content pub/link).
Thanks & Regards,
Smita
Can you please tell how can we get previous and next sibling of current selected node?
We you see in below screenshot we have some nodes in document, suppose currently we have access to node which has content pub target.
Can we get the next sibling node(which has content abc) and previous sibling node(which has content pub/link).
image.png
Please let me know, if there any more information needed.Thanks & Regards,
Smita
You do not have the required permissions to view the files attached to this post.
-
- Site Admin
- Posts: 172
- Joined: Tue Mar 20, 2018 5:28 pm
Re: How can we get previous and next sibling nodes
Post by Bogdan Dumitru »
Hello,
For this, you can inspect the content nodes of the parent element, somehow like this:
For this, you can inspect the content nodes of the parent element, somehow like this:
AuthorElement parentElement = ((AuthorElement)currentNode.getParent());
List<AuthorNode> allSiblings = parentElement.getContentNodes();
int currentNodeIndex = allSiblings.indexOf(currentNode);
AuthorNode previousSibling;
if (currentNodeIndex - 1 >= 0) {
previousSibling = allSiblings.get(currentNodeIndex - 1);
} else {
previousSibling = null;
}
AuthorNode nextSibling;
if (currentNodeIndex + 1 < allSiblings.size()) {
nextSibling = allSiblings.get(currentNodeIndex + 1);
} else {
nextSibling = null;
}
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