How to check for child node

Having trouble installing Oxygen? Got a bug to report? Post it all here.
SmitaPatil
Posts: 93
Joined: Mon Aug 08, 2022 2:32 pm

How to check for child node

Post 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
mihaela
Posts: 490
Joined: Wed May 20, 2009 2:40 pm

Re: How to check for child node

Post 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
Mihaela Calotescu
http://www.oxygenxml.com
Post Reply