tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Testing xmlgrep

At Tue, 16 Jun 2009 09:46:27 -0400,
matthew sporleder wrote:
> This tool is working pretty well for me to extract data by name but
> I'm trying to figure out how to only extract the elements when a
> sibling matches a subpattern.
> xmlgrep -x 'title%%{category[@term=NetBSD]}' atom.xml
>  doesn't seem to be working.  Any hints?  Also, is there a
> case-insensitive mode?
> Matt

First thing: I've fixed a bug related to this (%% did not match direct
successor) so please pull from the repository before trying the

To match an element only if a sibling matches a subpattern, the right
syntax is:

  $ xmlgrep -x '{title%%category[@term=NetBSD]}' atom.xml

For example, consider the file:

  <a a="a" b="b">
    <b a="a">
    <c b="b" />

And the command:

  $ xmlgrep -x '{b%%c[@b=b]}#' test.xml
  <b a="a">

I hope this helps.

As for a case-insensitive mode, there is none at the moment, but it
could be added easily.

Nhat Minh

Home | Main Index | Thread Index | Old Index