I'd like to parse this XML file:
XML file to parse:
<?xml version="1.0"?>
<Gist xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../schema/Gist.xsd">
<Name>AbsoluteValue</Name>
<Description>Determines the absolute value.</Description>
<PertinentData />
<Scenarios>
<Scenario>
<ID>CALCULATED</ID>
<Description>The value was used in the absolute value function.</Description>
<Template>
<NodeName />
<Text> is </Text>
<NodeValue />
<Text> because it is the absolute value of </Text>
<InputNameAsLink>Value</InputNameAsLink>
<Text> (</Text>
<InputValueAsLink>Value</InputValueAsLink>
<Text>).</Text>
</Template>
</Scenario>
<Scenario>
<ID>INPUT_IS_BLANK</ID>
<Description>The value is blank.</Description>
<Template>
<NodeName />
<Text> is blank since </Text>
<InputNameAsLink>Value</InputNameAsLink>
<Text> (</Text>
<InputValueAsLink>Value</InputValueAsLink>
<Text>) is blank.</Text>
</Template>
</Scenario>
</Scenarios>
</Gist>
I'd like returned to me the the Gist Name, and scenarios. So for the example file, I'd like AbsoluteValue and a list of scenarios (CALCULATED and INPUT_IS_BLANK). Correct me if I'm wrong, but the data structure to use would be
Map<String, List<String>>
How can I accomplish this in Java code? I'd like to use XPATHs if possible.
I was thinking this would be a proper XPATH expression to get each SCENARIO?
/*/Scenarios/Scenario/ID/*