Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/380.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在java中具有带前缀和不带前缀元素的Xpath_Java_Xml_Xpath_Namespaces - Fatal编程技术网

在java中具有带前缀和不带前缀元素的Xpath

在java中具有带前缀和不带前缀元素的Xpath,java,xml,xpath,namespaces,Java,Xml,Xpath,Namespaces,要在XPath/SOAP:Envelope/SOAP:Body/generic.GenericObject.configureInstanceWithResult/configInfo/equipment.PhysicalPort/description处获取值 及 从下面的XML <?xml version="1.0" encoding="UTF-8"?> <SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/e

要在XPath/SOAP:Envelope/SOAP:Body/generic.GenericObject.configureInstanceWithResult/configInfo/equipment.PhysicalPort/description处获取值 及

从下面的XML

<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
     <SOAP:Header>
          <header xmlns="xmlapi_1.0">
               <requestID>XXX</requestID>
          </header>
     </SOAP:Header>
     <SOAP:Body>
          <generic.GenericObject.configureInstanceWithResult xmlns="xmlapi_1.0">
               <deployer>deployer value</deployer>
               <synchronousDeploy>XXX</synchronousDeploy>
               <distinguishedName>XXX</distinguishedName>
               <includeChildren>XXX</includeChildren>
               <configInfo>
                    <equipment.PhysicalPort>
                         <actionMask>
                              <bit>XXX</bit>
                         </actionMask>
                         <administrativeState>XXX</administrativeState>
                         <loadBalanceAlgorithm>XXX</loadBalanceAlgorithm>
                         <description>XXX</description>
                    </equipment.PhysicalPort>
               </configInfo>
          </generic.GenericObject.configureInstanceWithResult>
     </SOAP:Body>
</SOAP:Envelope>
我无法更改Xml或xpath,因此需要拿出一个逻辑来处理它。
请告诉我如何处理它。

我很难理解名称空间,也许这样的构造有帮助/*[local name=description]是的,有帮助,但我无法更改Xpath。正在寻找一种解决方案,我可以在其中以一种工作方式设置名称空间上下文。然后我们可以帮你修好它。您需要将SOAP命名空间前缀注册到命名空间URIhttp://schemas.xmlsoap.org/soap/envelope/,并在执行XPath查询时使用它。您还需要在JavaGood point@MarkVeenstra中设置名称空间xmlns=xmlapi_1.0。OP的实现方式取决于您在Java中使用的XPathAPI。
<?xml version="1.0" encoding="UTF-8"?>
<SOAP:Envelope xmlns:SOAP="http://schemas.xmlsoap.org/soap/envelope/">
     <SOAP:Header>
          <header xmlns="xmlapi_1.0">
               <requestID>XXX</requestID>
          </header>
     </SOAP:Header>
     <SOAP:Body>
          <generic.GenericObject.configureInstanceWithResult xmlns="xmlapi_1.0">
               <deployer>deployer value</deployer>
               <synchronousDeploy>XXX</synchronousDeploy>
               <distinguishedName>XXX</distinguishedName>
               <includeChildren>XXX</includeChildren>
               <configInfo>
                    <equipment.PhysicalPort>
                         <actionMask>
                              <bit>XXX</bit>
                         </actionMask>
                         <administrativeState>XXX</administrativeState>
                         <loadBalanceAlgorithm>XXX</loadBalanceAlgorithm>
                         <description>XXX</description>
                    </equipment.PhysicalPort>
               </configInfo>
          </generic.GenericObject.configureInstanceWithResult>
     </SOAP:Body>
</SOAP:Envelope>