Find a given text in xml and return its position as an XPath
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
LICENSE
README.md
xml.xml
xmlgrep.py

README.md

Copyright (C) 2015 Łukasz Czerwiński

Xmlgrep

Find a given text return it position in a xml as an XPath

Website

https://github.com/wo3kie/xmlgrep

Requirements

python

How to use it?

$ cat xml.xml   
<?xml version="1.0"?>  
<messages>  
  <note ID="501">  
    <to>Tove</to>  
    <from>Jani</from>  
    <heading>Reminder</heading>  
    <body>Don't forget me this weekend!</body>  
  </note>  
  <note ID="502">  
    <to>Jani</to>  
    <from>Tove</from>  
    <heading>Re: Reminder</heading>  
    <body>I will not!</body>  
  </note>   
</messages>  
$ ./xmlgrep.py xml.xml "messages"  
name(/messages)  
  
$ ./xmlgrep.py xml.xml "note"  
name(/messages/note)  
  
$ ./xmlgrep.py xml.xml "ID"  
name(/messages/note/@ID)  
  
$ ./xmlgrep.py xml.xml "501"  
string(/messages[1]/note[1]/@ID)  
  
$ ./xmlgrep.py xml.xml "to"  
name(/messages/note/to)  
  
$ ./xmlgrep.py xml.xml "Tove"  
string(/messages[1]/note[2]/from[1])  
string(/messages[1]/note[1]/to[1])  
  
$ ./xmlgrep.py xml.xml "from"  
name(/messages/note/from)  
  
$ ./xmlgrep.py xml.xml "Jani"  
string(/messages[1]/note[2]/to[1])  
string(/messages[1]/note[1]/from[1])  
  
$ ./xmlgrep.py xml.xml "heading"  
name(/messages/note/heading)  
  
$ ./xmlgrep.py xml.xml "Reminder"  
string(/messages[1]/note[1]/heading[1])  
  
$ ./xmlgrep.py xml.xml "Don't"  
string(/messages[1]/note[1]/body[1])  
  
$ ./xmlgrep.py xml.xml "502"  
string(/messages[1]/note[2]/@ID)  
  
$ ./xmlgrep.py xml.xml "Re: Reminder"  
string(/messages[1]/note[2]/heading[1])  
  
$ ./xmlgrep.py xml.xml "I will"  
string(/messages[1]/note[2]/body[1])