public static String getXPathExpression()

in log4j-converter-config/src/main/java/org/apache/logging/converter/config/internal/XmlUtils.java [70:84]


    public static String getXPathExpression(Element node) {
        String tagName = node.getTagName();
        // Position of the node among siblings
        int position = 1;
        Node sibling = node.getPreviousSibling();
        while (sibling != null) {
            if (sibling instanceof Element && tagName.equals(((Element) sibling).getTagName())) {
                position++;
            }
            sibling = sibling.getPreviousSibling();
        }
        Node parent = node.getParentNode();
        String parentExpression = parent instanceof Element ? getXPathExpression((Element) parent) : "";
        return parentExpression + "/" + tagName + "[" + position + "]";
    }