======================================================================
\\// ||\/|| || _ ||\/|| ||@|| ~++~ ||@|| ||))
//\\ || || ||_ || || ||_|| || ||_|| ||\\
======================================================================
v 0.1.1
@GitHub: https://github.com/abhishekkr/rubygem_xml_motor
@RubyGems: http://rubygems.org/gems/xml-motor
for support contact:
mail: abhikumar163@gmail.com
http://www.twitter.com/aBionic
======================================================================
the main development for this algo (to be done in other languages too) is handled in
https://github.com/abhishekkr/axml-motor
and you could find the test-cases in there too, to proceed on your own
A new short XML Parsing Algorithm implemented directly in >500 lines.
An easy-to-use XML Parser without any Native Dependencies.
[How To Use]:
Loading:
+ $ gem install xml-motor
+ 'require' the 'xml-motor'
Usage:
[[ To Fetch Just Attribute Values ]]
str = {XML_DATA}
nodes_ = XMLMotor.splitter str
tags_ = XMLMotor.indexify nodes_
XMLMotor.xmlattrib 'attrib_to_fetch_value', nodes_, tags_
XMLMotor.xmlattrib 'attrib_to_fetch_value', nodes_, tags_, <_TAG_>
XMLMotor.xmlattrib 'attrib_to_fetch_value', nodes_, tags_, <_TAG_>, "ATTRIB_KEY"
XMLMotor.xmlattrib 'attrib_to_fetch_value', nodes_, tags_, <_TAG_>, "ATTRIB_KEY="
XMLMotor.xmlattrib 'attrib_to_fetch_value', nodes_, tags_, <_TAG_>, "ATTRIB_KEY=ATTRIB_VALUE"
XMLMotor.xmlattrib 'attrib_to_fetch_value', nodes_, tags_, <_TAG_>, "=ATTRIB_VALUE"
[[ To Search More Than One QUERIES ]]
str = {XML_DATA}
nodes_ = XMLMotor.splitter str
tags_ = XMLMotor.indexify nodes_
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_"
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE"
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, "ATTRIB_KEY=ATTRIB_VALUE"
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, "ATTRIB_KEY"
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, "='ATTRIB_VALUE'"
>>>>> for having root-node-tag also in returned result <<<<<
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", nil, true
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE", true
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", ["ATTRIB_KEY=ATTRIB_VALUE"], true
nodes_array = XMLMotor.xmldata nodes_, tags_, "_TAG_", ["KEY1=VALUE1", "KEY2=VALUE2"...], true
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, ["KEY1=VALUE1", "KEY2=VALUE2"...], true
nodes_array = XMLMotor.xmldata nodes_, tags_, nil, "ATTRIB_KEY=ATTRIB_VALUE", true
[[ To Search Just One QUERY ]]
nodes_array = XMLMotor.get_node_from_file "_XML_FILE_", "_TAG_"
nodes_array = XMLMotor.get_node_from_file "_XML_FILE_", "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE"
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", "_TAG_"
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE"
nodes_array = XMLMotor.get_node_from_file "_XML_FILE_", nil, "ATTRIB_KEY=ATTRIB_VALUE"
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", nil, "ATTRIB_KEY=ATTRIB_VALUE"
>>>>> for having root-node-tag also in returned result <<<<<
nodes_array = XMLMotor.get_node_from_file "_XML_FILE_", "_TAG_", nil, true
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", "_TAG_", "ATTRIB_KEY=ATTRIB_VALUE", true
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", "_TAG_", ["ATTRIB_KEY=ATTRIB_VALUE"], true
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", "_TAG_", ["KEY1=VALUE1", "KEY2=VALUE2"...], true
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", "_TAG_", ["KEY1=VALUE1", "KEY2=VALUE2"...], true
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", nil, "ATTRIB_KEY=ATTRIB_VALUE", true
nodes_array = XMLMotor.get_node_from_content "_XML_DATA_", nil, ["KEY1=VALUE1", "KEY2=VALUE2"...], true
Example Calls As Code:
+ XMLMotor.get_node_from_content "aba", "A"
RETURNS: ["a", "ba"]
+ XMLMotor.get_node_from_content "aba", "B.A"
RETURNS: ["ba"]
+ XMLMotor.get_node_from_content "aba", "A", "i='1'"
RETURNS: ["a"]
To turn on the verbosity for errors in XML-Motor, set an Environment value for 'VERBOSE'.
=====================================================================
=====================================================================