-1

I have a xml retrieved from seedlist service like this.

<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>

I want to retrieve /mypoc

<wplc:field id="securecontext">/mypoc</wplc:field>

wplc tag have common local name field So I am unable to retrieve this.

I am using Abdera parser to parse xml.

If it is possible I want to retrieve this using QName or Feed.getSimpleExtension() method

Dan Lowe
  • 51,713
  • 20
  • 123
  • 112

1 Answers1

0

If you want to stick with Abdera - that is Atom-specific - I don't think you can get that value with a single call: you need to enumerate all the wplc:field element using getFirstChild() on the parent and then getNextSibling(), and check for the right id value using getAttributeValue().

If you use a generic XML parser you should be able to get that value directly using a XPath like:

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

(having defined the prefixes atom for http://www.w3.org/2005/Atom and wplc for http://www.ibm.com/wplc/atom/1.0)

MiMo
  • 11,793
  • 1
  • 33
  • 48
  • HI MiMo thanks for reply-I tried this `XPathExpression xp = XPathFactory.newInstance().newXPath().compile("//atom/wplc[@id='securecontext']"); String href = xp.evaluate(doc);` and I am getting this error `Unsupported context item: org.apache.abdera.parser.stax.FOMDocument@6d4eed8 ` – Azeez Ahmad Mar 22 '13 at 18:50