Page 1 of 1

How to check for child node

Posted: Wed Jan 18, 2023 11:28 am
by SmitaPatil
Hi Team,
Suppose I have access to below entry node.
I wanted to check if leaderchar is present or not in entry anywhere.
as we don't have leaderchar as direct child of entry.
I can think of get all child nodes then child of child nodes and check if it is leaderchar or not with the existing method which I know.
But instead of verifying for all node one by one. I am wondering if we have any method in oxygen which will check if childnode is present with given name (can be present as grand child of node) in the given node.

<entry>
<para>
<paratext> check <bold><bold/>opportunity
<leader source="dtbl">
<leaderchar>with notice and an opportunity</leaderchar>
</leader> check
<leader source="dtbl">
<leaderchar>with notice and an opportunity</leaderchar>
</leader>
</paratext>
</para>
</entry>

Please let me know if you need any more details.

Thanks & Regards,
Smita

Re: How to check for child node

Posted: Wed Jan 18, 2023 12:10 pm
by mihaela
Hello,

The method that you tried (checking the child nodes recursively) is the proper way of searching for a specific node.

Another way to do this, but only if you search inside a node from the document (not from an AuthorDocumentFragment), is to use the AuthorDocumentController.findNodesByXPath(String, AuthorNode, boolean, boolean, boolean, boolean) API (also check the other signatures for findNodesByXPath method).

Best Regards,
Mihaela