Hello,
I am using LightXML to extract element nodes which pertain to musical parameters. I push the valuable elements to an array and then to a text file. Currently, I am struggling with how to exclude/include certain node elements based on their context.
For instance, I want to extract all durations that have this context:
</pitch>
<duration>1024</duration>
But I don’t want to extract durations that have these contexts.
<backup>
<duration>1024</duration>
</backup>
<rest />
<duration>1024</duration>
Thank you very much!
Nakul
I’m not sure what you mean by “context”, but if it can be described in XPath, my sweet EzXML.jl package is very helpful. It defines findall(xpath, node)
that returns all XML nodes matching xpath
under node
.
3 Likes
I am examining EzXML right now. I’ve never heard of XPath but it seems very promising.
To elaborate on my specific needs and the context criteria: I want to only collect duration node elements which are preceded by pitch node elements. Sometimes, duration node elements are preceded by backup nodes or rest nodes, which I want to exclude from my collection. Is there an XPath query for that?
Thanks!