I have many xml files to filter and I need to do it with JOOX. I'm using it with XPATH to filter by one condition but I need at least two conditions, I would like to be a dynamic filtering to which I could add more filters if it's requested, but at least I need two. A priori I don't know the structure of the xml and maybe the two conditions reference to siblings nodes. The structures of my xml are like this:
<Message>
<Header>
<SequenceNumber>12345</SequenceNumber>
<OriginSystem>xxx</OriginSystem>
<Timestamp>141</Timestamp>
<ContentType>123</ContentType>
</Header>
<OriginCenter>
<CR id="xx" />
<LI id="We" />
</OriginCenter>
<MessageType>
<Type1 id="myId">
<Id>LAV6.OIR.282O</Id>
<TimeStampValue value="1430275652165" />
<State>
<UpToDate value="YES" />
<InterlockedRoute value="YES" routeType="Itinerario" />
<Sliding value="NOT" routeType="" />
<Blocked value="NOT" />
<Plaques>
<PlaqueO value="NOT" counter="0" />
<PlaqueV value="NOT" />
</Plaques>
<Dual value="YES" active="YES" />
</State>
<Flights number="1">
<Flight index="1" Id="09070" />
</Flights >
</Type1>
</MessageType>
<Optionals>
<Parameter1 name="" value="" />
<Parameter2 name="" value="" />
<Parameter3 name="" value="" />
</Optionals>
</Message>
An example could be: find all the messages where PlaqueV has the property value with value NOT and Blocked has the property value with value NOT.
I would do it knowing the depth of the structure with xpath using: //Blocked[@value='NOT']/../Plaques/PlaqueV[@value='NOT']
How I could do it dinamically without knowing the structure?
Thanks!
Thank you splash58, I finally solved it creating a dynamic string and passing it to JOOX.
I mean: JOOX.$(file).xpath(conditions);
Where conditions is the dynamic string I created using your advice:
Root[.//TAG[@property='value'] and .//TAG[content='value'] and...]