To access the values id1 & id2 im iterating over every value in the XML and if I find a tag named id1 or id2 I read its value into a variable. Is there a better method of reading the values id1 & id2 ?
<begin>
<total>1</total>
<values>
<factor>
<base>test</base>
<id1>id1</id1>
<id2>id2</id2>
<val>val2</val>
<newval>val1</newval>
</factor>
</values>
</begin>
If you use XPath, you can extract values directly from the Document object. In your case, the XPath to get to
id1would be/begin/id1.