[XMLStarlet] Edit+insert elements?
by littlebigman from LinuxQuestions.org on (#5P4J8)
Hello,
In case someone here already knows how to use the XMLStarlet application to edit KML files, I need to...
1. Check if kml/Document/name exists: If it does, edit its name; If it doesn't, insert a new element
2. Add a sibling to all LineString elements.
It looks like XMLStarlet supports it, but I don't know enough about XPath yet to figure it out.
Thank you.
Code:xml el input.kml
kml
kml/Document
kml/Document/Placemark
kml/Document/Placemark/name
kml/Document/Placemark/ExtendedData
kml/Document/Placemark/ExtendedData/Data
kml/Document/Placemark/ExtendedData/Data/value
kml/Document/Placemark/LineString
kml/Document/Placemark/LineString/coordinates
In case someone here already knows how to use the XMLStarlet application to edit KML files, I need to...
1. Check if kml/Document/name exists: If it does, edit its name; If it doesn't, insert a new element
2. Add a sibling to all LineString elements.
It looks like XMLStarlet supports it, but I don't know enough about XPath yet to figure it out.
Thank you.
Code:xml el input.kml
kml
kml/Document
kml/Document/Placemark
kml/Document/Placemark/name
kml/Document/Placemark/ExtendedData
kml/Document/Placemark/ExtendedData/Data
kml/Document/Placemark/ExtendedData/Data/value
kml/Document/Placemark/LineString
kml/Document/Placemark/LineString/coordinates