Skip to content

Commit a530330

Browse files
committed
new_rep
1 parent 7c68bbd commit a530330

25 files changed

+2858
-8
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/Manifest*.toml
2+
/src/debug_*

Project.toml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,15 @@
11
name = "XMLWalker"
22
uuid = "9cd7548c-8553-4cf3-b148-d77f511bbfb9"
33
authors = ["Roman Mironov"]
4-
version = "1.0.0-DEV"
4+
version = "0.1.0"
5+
6+
[deps]
7+
InteractiveUtils = "b77e0a4c-d291-57a0-90e8-8db25a27a240"
8+
OrderedCollections = "bac558e1-5e72-5ebc-8fee-abe8a469f55d"
59

610
[compat]
11+
InteractiveUtils = "1.11.0"
12+
OrderedCollections = "1.8.1"
713
julia = "1.6.7"
814

915
[extras]

README.md

Lines changed: 47 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,48 @@
1-
# XMLWalker
21

3-
[![Build Status](https://github.com/Manarom/XMLWalker.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/Manarom/XMLWalker.jl/actions/workflows/CI.yml?query=branch%3Amain)
2+
3+
[![Build Status](https://github.com/your-GitHub-username/XMLWalker.jl/actions/workflows/CI.yml/badge.svg?branch=main)](https://github.com/Manarom/XMLWalker.jl/actions/workflows/CI.yml?query=branch%3Amain)
4+
5+
[![dev](https://img.shields.io/badge/docs-dev-blue.svg)](https://manarom.github.io/XMLWalker.jl)
6+
7+
# XMLWalker.jl
8+
9+
After loading the XML file using `XML.jl`, all data is stored in an encapsulated, tree-like structure of `Nodes`. Each node element has a children field, which is a vector of child `Nodes`, as well as other fields like `attributes`, `value` etc. `XMLWalker.jl` provides tools for traversing the XML tree using a set of matchers that check the content of nodes. Matchers can be created from strings and combined into chain strings, forming a sequence of matchers to find nodes that meet multiple content restrictions. The function `XMLWalker.find_nodes` converts input string to machers, recursively applies these matchers and returns a vector of nodes that satisfy the specified conditions.
10+
11+
# Quick start
12+
```julia
13+
import Pkg
14+
Pkg.add("XMLWalker.jl")
15+
16+
import XMLWalker
17+
import XML
18+
19+
xml_file = XML.read(xml_file,Node) # loads data as a structure with multiple embedded nodes
20+
matched_nodes = XMLWalker.find_nodes(starting_node,"A/[B,C]/D") # finds nodes, matching the
21+
# specified path (chain) or single matching "A"=>"B"=>"D" or "A"=>"C"=>"D" route
22+
```
23+
Search string can contain various elements like regular expressions, partial matching patterns, patterns unions and intersections, searching nodes by content etc.
24+
25+
More complicated search examples:
26+
```julia
27+
XMLWalker.find_nodes(starting_node,"*/[[\\d]::regex].attributes({id,p1})/*/D")
28+
# will search for all subnodes of a starting_node that has:
29+
# - has field `tag` containing digits,
30+
# - field `attributes` with both "id" and "p1" keys
31+
# - any subnode
32+
# - sub-subnode with field tag equal to "D"
33+
XMLWalker.find_nodes(starting_node,"[ABC,BBB].parameters=[A,B,C]") # searches for the nodes that has "ABC" or "BBB" tag
34+
# and "A","B" or "C" values of `parameters` field
35+
XMLWalker.find_nodes(starting_node,"*.attributes({id,*par})",:Name) # searches for nodes with any Name field, but with
36+
# attributes field, which must have key "id" and any key which contains "par" as a substring
37+
```
38+
It is also possible to create a matcher objects from string using `@to_matcher_str` macro.
39+
This macro can be usefull for multiple searches of the same pattern.
40+
41+
```julia
42+
using XMLWalker
43+
matcher_object =XMLWalker.to_matcher"[[\\d]::regex].attributes({id,p1})" # returns matchers objects vector
44+
XMLWalker.find_nodes(starting_node1 , matcher_object[])
45+
XMLWalker.find_nodes(starting_node2 , matcher_object[])
46+
```
47+
Full search string specification and package API are availabel at [documentation page](https://manarom.github.io/XMLWalker.jl/).
48+

0 commit comments

Comments
 (0)