[jxpath] retrieving sub xml

classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

[jxpath] retrieving sub xml

Markos Charatzas
Hi there,

Is it possible to retrieve a subset of an XML document using the jxpath api?
The JXPathContext#getValue(String) method returns it in rich formatted text.

Thanks in advance,
Markos Charatzas

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [jxpath] retrieving sub xml

Markos Charatzas
Maybe it requires some clarification.

When I say rich formattted text, I get all the values evaluated by the xpath
expression, but without the tags. Just tab, return characters and values of
tags.

e.g. in an xml of
<persons>
        <person>
                <name>foo</name>
                <age>20</age>
        </person>
        <person>
                <name>bar</name>
                <age>25</age>
        </person>
                <name>foobar</name>
                <age>20</age>
</persons>

I want to retrieve just all <person> elements with age = 20
(xpath "persons/person[age=20]")

Is it feasible using the jxpath API?

Thanks in advance,
Markos

On Monday 13 June 2005 12:36, Markos Charatzas wrote:

> Hi there,
>
> Is it possible to retrieve a subset of an XML document using the jxpath
> api? The JXPathContext#getValue(String) method returns it in rich formatted
> text.
>
> Thanks in advance,
> Markos Charatzas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [jxpath] retrieving sub xml

Dmitri Plotnikov
Markos,
 
The method you need to use is context.selectSingleNode
 
- Dmitri

Markos Charatzas <[hidden email]> wrote:
Maybe it requires some clarification.

When I say rich formattted text, I get all the values evaluated by the xpath
expression, but without the tags. Just tab, return characters and values of
tags.

e.g. in an xml of




foo
20




bar
25


foobar
20



I want to retrieve just all
elements with age = 20
(xpath "persons/person[age=20]")

Is it feasible using the jxpath API?

Thanks in advance,
Markos

On Monday 13 June 2005 12:36, Markos Charatzas wrote:

> Hi there,
>
> Is it possible to retrieve a subset of an XML document using the jxpath
> api? The JXPathContext#getValue(String) method returns it in rich formatted
> text.
>
> Thanks in advance,
> Markos Charatzas
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]

Reply | Threaded
Open this post in threaded view
|

Re: [jxpath] retrieving sub xml

Markos Charatzas
Hey Dimitri,

Thanks for taking the time.
I've seen this method but as far as I can see it returns a reference to the
node (DeferredElementNSImpl, using xerces) which has all methods to play with
it.

What I really want is the textual representation of the node inc. the tags. I
was hoping that #toString() would return that but my assumption failed me. Am
I missing smth?

Thanks again,
Markos

On Tuesday 14 June 2005 18:37, Dmitri Plotnikov wrote:

> Markos,
>
> The method you need to use is context.selectSingleNode
>
> - Dmitri
>
> Markos Charatzas <[hidden email]> wrote:
> Maybe it requires some clarification.
>
> When I say rich formattted text, I get all the values evaluated by the
> xpath expression, but without the tags. Just tab, return characters and
> values of tags.
>
> e.g. in an xml of
>
>
>
>
> foo
> 20
>
>
>
>
> bar
> 25
>
>
> foobar
> 20
>
>
>
> I want to retrieve just all
> elements with age = 20
> (xpath "persons/person[age=20]")
>
> Is it feasible using the jxpath API?
>
> Thanks in advance,
> Markos
>
> On Monday 13 June 2005 12:36, Markos Charatzas wrote:
> > Hi there,
> >
> > Is it possible to retrieve a subset of an XML document using the jxpath
> > api? The JXPathContext#getValue(String) method returns it in rich
> > formatted text.
> >
> > Thanks in advance,
> > Markos Charatzas
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: [hidden email]
> > For additional commands, e-mail: [hidden email]
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: [hidden email]
> For additional commands, e-mail: [hidden email]

---------------------------------------------------------------------
To unsubscribe, e-mail: [hidden email]
For additional commands, e-mail: [hidden email]