如何使用java获取名称空间属性的xpath
如何使用java获取以下jaxrs:server元素的xpath?我解决不了如何使用java获取名称空间属性的xpath,java,xml,xpath,jax-rs,jax-ws,Java,Xml,Xpath,Jax Rs,Jax Ws,如何使用java获取以下jaxrs:server元素的xpath?我解决不了 <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schem
<?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.springframework.org/schema/beans" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd http://cxf.apache.org/bindings/soap http://cxf.apache.org/schemas/configuration/soap.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<bean id="discoverRSByeBean" class="discovery.hello.DiscoverRSBye"/>
<jaxrs:server id="discoverRSBye" address="/discover_r_s_bye">
<jaxrs:serviceBeans>
<ref bean="discoverRSByeBean"/>
</jaxrs:serviceBeans>
</jaxrs:server>
<bean id="DiscoveryRSHelloBean" class="discovery.hello.DiscoveryRSHello"/>
<jaxrs:server id="DiscoveryRSHello" address="/discovery_r_s_hello">
<jaxrs:serviceBeans>
<ref bean="DiscoveryRSHelloBean"/>
</jaxrs:serviceBeans>
</jaxrs:server>
</beans>
hardcodednamespacteresolver
类拥有我需要使用的所有名称空间,这是我在本文中完成的。我在.NET中测试了这一点,我认为XPATH就是XPATH,对吗
"//*[namespace-uri(.)='http://cxf.apache.org/jaxrs']"
让我知道它是否有效。
节点位于默认名称空间中,如果您正确地阅读了文章,并且我正确地理解了文章,那么这应该是有效的::beans/jaxrs:server
注意xpath开头的冒号(:
)
"//*[namespace-uri(.)='http://cxf.apache.org/jaxrs']"