[XML] How to get sub-elements (nodes + texts)?
Hello,
Since I'm not getting the subscription e-mails, I can't ask in those tools' forums on Sourceforge. I tried xidel and XMLStarlet as command line tools to parse XML files and grab everything (elements + text) below given nodes… to no avail: The tools only return the texts it finds, not the elements. Code:
<?xml version="1.0" encoding="UTF-8"?> Code:
xidel -s input.gpx -e "//trk/trkseg/*" Code:
37.5 Thank you. -- Edit: Yes, indeed. By default, only texts within elements are output. → Code:
xidel input.gpx -e "//trkseg/*/outer-xml(.)" |
With your example as MyFile.xml
Example using xml.etree: Code:
#!/usr/bin/python Code:
python ./MyFile.py |
Yes, it works fine with Python and ET/BS, but I needed a lighter solution, with just a single binary.
Another way to solve it: Code:
xidel input.gpx -se "//trk/trkseg/*" --printed-node-format xml |
All times are GMT -5. The time now is 06:48 PM. |