Article 5P4J8 [XMLStarlet] Edit+insert elements?

[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/coordinateslatest?d=yIl2AUoC8zA latest?i=VH1w7P7qWow:05PsHP6ByTc:F7zBnMy latest?i=VH1w7P7qWow:05PsHP6ByTc:V_sGLiP latest?d=qj6IDK7rITs latest?i=VH1w7P7qWow:05PsHP6ByTc:gIN9vFwVH1w7P7qWow
External Content
Source RSS or Atom Feed
Feed Location https://feeds.feedburner.com/linuxquestions/latest
Feed Title LinuxQuestions.org
Feed Link https://www.linuxquestions.org/questions/
Reply 0 comments