I am trying to parse through an XML which looks something like
<e:UDFs>
<e:UDF name="Comments_20for_20Approvers">Cloning req 379023 - bypassing approvals</e:UDF>
<e:UDF name="Delivery_20Model">
<e:UDSElement>
<e:Description>
<e:value locale="en">Platinum</e:value>
</e:Description>
</e:UDSElement>
</e:UDF>
<e:UDF name="Incentive_20Plan_20Code">
<e:UDSElement>
<e:Description>
<e:value locale="en">RRP</e:value>
</e:Description>
</e:UDSElement>
</e:UDF>
<e:UDF name="Job_Code">ICO050</e:UDF>
<e:UDF name="Justification">
<e:UDSElement>
<e:Description>
<e:value locale="en">Budgeted New</e:value>
</e:Description>
</e:UDSElement>
</e:UDF>
<e:UDF name="Range_20Maximum"/>
<e:UDF name="Target">1000</e:UDF>
<e:UDF name="Underutilization_20Status">
<e:UDSElement>
<e:Description>
<e:value locale="en">Underutilized for Minorities</e:value>
</e:Description>
</e:UDSElement>
</e:UDF>
</e:UDFs>
As u can see there are several tags with tag named 'UDF' with different attributes like "Comments_20for_20Approvers" , "Delivery_20Model" and so on.
I want to parse through this XML and store values of these tags in different variables. For example value of in a variable called comments, in a variable called incentive.
I want to use XMLstramreader. Following is my XMLstream
Xmlstreamreader reader = new Xmlstreamreader(xmlBody);
Following is my code to go through the 'reader'
while(reader.hasNext())
{
if (<check of a particular attribute>)
{
//do something
}
reader.next();
}
Not sure how to look for attribute value in the IF statement above.
Any help is greatly appreciated.