Skip to content

Commit aec5e64

Browse files
committed
Add the helper function and global variable
+ Add the helper function to see if the tag name is present inside the given path array. + Add the stack to know the current depth wrto the required path.
1 parent fd82b2d commit aec5e64

1 file changed

Lines changed: 21 additions & 0 deletions

File tree

src/main/java/org/json/XML.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,27 @@ else if (token instanceof String) {
469469
}
470470
}
471471

472+
473+
private static Stack<String> stack = new Stack<String>();
474+
475+
/**
476+
* Search if the tag name is present in the path.
477+
*
478+
* @param str - The string array with the paths
479+
* @param tagName - The required tag name to find
480+
* @return - true if the required tagname is found in the paths
481+
*/
482+
private static boolean isPresent(String[] str, String tagName) {
483+
str = Arrays.copyOf(str, str.length - 1);
484+
485+
for (int i = 0; i < str.length; i += 1) {
486+
if (tagName.equals(str[i]))
487+
return true;
488+
}
489+
490+
return false;
491+
}
492+
472493
/**
473494
* Scan the content following the named tag, attaching it to the context.
474495
*

0 commit comments

Comments
 (0)