diff --git a/ph-xml/src/main/java/com/helger/xml/XMLHelper.java b/ph-xml/src/main/java/com/helger/xml/XMLHelper.java index 5d5ac2862..3569d9b42 100644 --- a/ph-xml/src/main/java/com/helger/xml/XMLHelper.java +++ b/ph-xml/src/main/java/com/helger/xml/XMLHelper.java @@ -566,7 +566,18 @@ private static String _getPathToNode (@Nonnull final Node aNode, break; } - final StringBuilder aName = new StringBuilder (aCurNode.getNodeName ()); + final String sNamespaceURI = aCurNode.getNamespaceURI (); + + final StringBuilder aName = new StringBuilder (); + if (nNodeType == Node.ATTRIBUTE_NODE) + aName.append ('@'); + if (StringHelper.hasText (sNamespaceURI)) + { + aName.append (funGetNSPrefix.apply (sNamespaceURI)); + aName.append (aCurNode.getLocalName ()); + } + else + aName.append (aCurNode.getNodeName ()); final Node aParentNode; if (nNodeType == Node.ATTRIBUTE_NODE) @@ -633,11 +644,7 @@ private static String _getPathToNode (@Nonnull final Node aNode, // Avoid trailing separator aRet.insert (0, sSep); } - aRet.insert (0, aName); - aRet.insert (0, funGetNSPrefix.apply (aCurNode.getNamespaceURI ())); - if (nNodeType == Node.ATTRIBUTE_NODE) - aRet.insert (0, '@'); // goto parent aCurNode = aParentNode;