I'm trying to get partial data from my xml file,
The source file is like this:
<Odds>
<Match ID="101" Time="A">
<Event type="Home">
<Score="1"/>
</Event>
<Event type="Away">
<Score="2"/>
</Event>
</Match>
<Match ID="102" Time="B">
<Event type="Home">
<Score="1"/>
</Event>
<Event type="Away">
<Score="2"/>
</Event>
</Match>
</Odds>
I want to get the Odds, Match, Event, Score tags where Event type match "Home" only.
That is, the result is as below:
<Odds>
<Match ID="101" Time="A">
<Event type="Home">
<Score="1"/>
</Event>
</Match>
<Match ID="102" Time="B">
<Event type="Home">
<Score="1"/>
</Event>
</Match>
</Odds>
I'm fresh to XML, have read some books.
Tried to add criteria in WHERE of xquery and RETURN the parent node.
But the result always returns the Match with full child nodes.
That is, there is no difference between the result and the original one.
Is there any good way to do to get rid of those events that the type is not Home?
Thanks for the help!