[jdom-interest] Question about ElementScanner
Michael Smith
mikesmi at nc.rr.com
Mon Mar 28 07:42:12 PST 2005
Thanks for all the responses to my question. I did finally get this working
using Xpath. I was avoiding an XSLT solution because I'd rather do as much
as I can in Java if possible (personal preference). I'm new to JDOM, so just
getting my sea legs as to where the boundaries are. I assumed someone else
had desired to do what I was seeking to do and had already established a
Java/JDOM solution.
-----Original Message-----
From: Phil Weighill-Smith [mailto:phil.weighill-smith at volantis.com]
Sent: Saturday, March 26, 2005 4:22 PM
To: Phil Weighill-Smith; Michael Smith; jdom-interest at jdom.org
Subject: RE: [jdom-interest] Question about ElementScanner
Which then made me think: why not use XSLT instead?
Phil :n.
-----Original Message-----
From: Phil Weighill-Smith
Sent: Sat 26/03/2005 13:50
To: Michael Smith; jdom-interest at jdom.org
Cc:
Subject: RE: [jdom-interest] Question about ElementScanner
Try using XPath to select all elements you want to replace then
manipulate these elements via the JDOM API.
E.g. to find all elements called "x" anywhere in a document use the
XPath "//x", or to find all elements called "x" with an attribute "a" with
the value "example" you could use the XPath "//x[@a='example']". XPath is
very powerful for performing potentially conditional selection of elements,
attributes, text nodes etc. especially if you use the various axes and
built-in functions.
Phil :n)
-----Original Message-----
From: Michael Smith [mailto:mikesmi at nc.rr.com]
Sent: Fri 25/03/2005 16:38
To: jdom-interest at jdom.org
Cc:
Subject: [jdom-interest] Question about ElementScanner
Hi there,
I want to create a way to search through XML documents and
perform a search and replace on certain elements regardless of their place
in the hierarchy. I'm thinking ElementScanner is useful here? If so, can
someone point me to an example of its use. If not, can you suggest
another/better way?
Thanks,
Mike
More information about the jdom-interest
mailing list