https://github.com/nattfalk/xml-filter
Extremly simple .NET Core command-line tool for filtering XML files
https://github.com/nattfalk/xml-filter
command-line-tool csharp net-core-3 xml
Last synced: 6 months ago
JSON representation
Extremly simple .NET Core command-line tool for filtering XML files
- Host: GitHub
- URL: https://github.com/nattfalk/xml-filter
- Owner: nattfalk
- License: mit
- Created: 2020-01-20T12:25:21.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-11T19:34:29.000Z (almost 6 years ago)
- Last Synced: 2025-04-06T01:41:19.237Z (9 months ago)
- Topics: command-line-tool, csharp, net-core-3, xml
- Language: C#
- Size: 17.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# xml-filter

Simple .NET Core command-line tool for filtering XML files using XPath
## Prerequisites
- .NET CORE 3
## Installing
```
> git clone https://github.com/nattfalk/xml-filter.git
> cd xml-filter
> dotnet build
```
## Usage
```
xml-filter -i [input-file] -x [xpath-filter] [additional options]
-i, --input Required. Input XML file
-x, --xpath Required. XPath filter used to filter the elements
-o, --output Output XML file
-c, --contents Displays contents from given number of elements after applied filter
```
## Examples
### Example 1
Apply filter and display number of filtered elements
```
> xml-filter -i testfiles\cd_catalog.xml -x /CATALOG/CD[COUNTRY='EU']
```
Results in
```
Filter resulted in 5 of totally 26 elements.
```
### Example 2
Apply filter and display contents of first 2 filtered elements
```
> xml-filter -i testfiles\cd_catalog.xml -x /CATALOG/CD[COUNTRY='EU'] -c 2
```
Results in
```xml
Filter resulted in 5 of totally 26 elements.
Displaying contents of 2 elements
---------------------------------
Eros
Eros Ramazzotti
EU
BMG
9.90
1997
Romanza
Andrea Bocelli
EU
Polydor
10.80
1996
```
### Example 3
Apply filter and save the filtered elements to file
```
> xml-filter -i testfiles\cd_catalog.xml -o result.xml -x /CATALOG/CD[COUNTRY='EU']
```
Results in
```
Filter resulted in 5 of totally 26 elements.
'test.xml' saved!
```
## Authors
- **Michael Nattfalk** (michaelnattfalk@gmail.com)
## License
[](http://badges.mit-license.org)
This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details