Closed nicolasessisbreton closed 3 years ago
I'd use an existing xml parser for this. What's wrong with using XPath? It seems to be the right tool for the job. Besides, questions like this belong on stackoverflow with the [tatsu] tag.
With XPath it should be something like //city[.//capital[.="yes"]]
What would be the approach to grab all the capitals in the xml below?
Here are some attempts.
approach #1
approach #2
are there other ways?
This example is simplified, the condition on the element to grab could be arbitrarily complex. (think XPath) XPath is nice but has the same problem then approach #1 (fragile). Handling the task with a grammar gives a maintainable set of complex extractors. (define only the bit needing extraction, handling of massive xml,...)