使用java检索id为的XML元素

使用java检索id为的XML元素,java,xml-parsing,atom-feed,qnames,Java,Xml Parsing,Atom Feed,Qnames,我有一个从种子列表服务中检索到的xml,如下所示 <atom:feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:wplc="http://www.ibm.com/wplc/atom/1.0" xmlns:atom="http://www.w3.org/2005/Atom"> <atom:link href=

我有一个从种子列表服务中检索到的xml,如下所示

<atom:feed xmlns:opensearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:wplc="http://www.ibm.com/wplc/atom/1.0" xmlns:atom="http://www.w3.org/2005/Atom">
  <atom:link href="/wps/images/icons/scope_search_wcm.gif" rel="icon"/>
  <wplc:field id="name">Locations</wplc:field>
  <wplc:field id="contentSourceType">Seedlist</wplc:field>
  <wplc:field id="defaultcontext">/poc</wplc:field>
  <wplc:field id="effectivedate">1354640637000</wplc:field>
  <wplc:field id="modifier">uid=wpsadmin,o=defaultWIMFileBasedRealm</wplc:field>
  <wplc:field id="securecontext">/mypoc</wplc:field>
  <wplc:field id="search_controllable_uuid">f2bedbba-724e-420b-b066-5d0fef04c421</wplc:field>
  <wplc:field id="locale">en</wplc:field>
wplc
标记具有公共本地名称
字段
所以我无法找回这个

我正在使用
Abdera
解析器解析xml


如果可能的话,我想使用
QName
Feed.getSimpleExtension()
方法来检索这个值。如果您想坚持使用Abdera,这是Atom特有的,我认为您不可能通过单个调用获得该值:您需要使用
getFirstChild()枚举所有
wplc:field
元素
,然后使用
getAttributeValue()
检查正确的
id

如果使用通用XML解析器,则应该能够使用XPath直接获取该值,如:

/atom:feed/wplc:field[@id='securecontext']

(已为
http://www.w3.org/2005/Atom
http://www.ibm.com/wplc/atom/1.0

您好,谢谢您的回复-我尝试了这个
XPathExpression xp=XPathFactory.newInstance().newXPath().compile(“//atom/wplc[@id='securecontext']”);字符串href=xp.evaluate(doc)我得到了这个错误
不支持的上下文项:org.apache.abdera.parser.stax。FOMDocument@6d4eed8
/atom:feed/wplc:field[@id='securecontext']