dom4j解析xml

问题遇到的现象和发生背景

dom4j解析xml 获取节点的全部路径
结果就是子节点的属性字段名不能跟父的一样

问题相关代码,请勿粘贴截图
<?xml version="1.0" encoding="utf-8"?>

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <soapenv:Body>
    <hgwTerminalRestartResponse xmlns="http://www.example.org/MobileLoadingMachine/">
      <responseStr xmlns="">&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;root&gt;&lt;resultCode&gt;3&lt;/resultCode&gt;&lt;/root&gt;</responseStr>
    </hgwTerminalRestartResponse>
  </soapenv:Body>
</soapenv:Envelope>


运行结果及报错内容

运行结果:
/soapenv:Envelope
/soapenv:Envelope/soapenv:Body
/soapenv:Envelope/soapenv:Body/[name()='hgwTerminalRestartResponse']
/soapenv:Envelope/soapenv:Body/
[name()='hgwTerminalRestartResponse']/responseStr
后面body的有问题

我的解答思路和尝试过的方法

多次尝试:把hgwTerminalRestartResponse xmlns改成xmlns1 和responseStr的xmlns改成xmlns2结果就可以了,为什么会这样
还有就是如果不改这个xmlns的名称怎么解析。

我想要达到的结果

预期达到的效果
/soapenv:Envelope
/soapenv:Envelope/soapenv:Body
/soapenv:Envelope/soapenv:Body/hgwTerminalRestartResponse
/soapenv:Envelope/soapenv:Body/hgwTerminalRestartResponse/responseStr

这是dom4j解析的默认设置:getPath()方法最终走到类AbstractElement这里:

/**
     * Returns the XPath expression to match this Elements name which is
     * getQualifiedName() if there is a namespace prefix defined or if no
     * namespace is present then it is getName() or if a namespace is defined
     * with no prefix then the expression is [name()='X'] where X = getName().
     *
     * @return DOCUMENT ME!
     */
    public String getXPathNameStep() {
        String uri = getNamespaceURI();

        if ((uri == null) || (uri.length() == 0)) {
            return getName();
        }

        String prefix = getNamespacePrefix();

        if ((prefix == null) || (prefix.length() == 0)) {
            return "*[name()='" + getName() + "']";
        }

        return getQualifiedName();
    }

看一下注释,或者if-else走一走就知道了