[Added robotframework-users back to Cc.]
2014-10-04 9:08 GMT+03:00 Ganesh Kumbhar <
gbkum...@gmail.com>:
> Hi
> I have xml file common.xml.and one in tag <RollNo>39</RollNo>
> so I have to get that text i.e. 39 and update that text to some other value
> or just increment by 1.
> I successfully able to get text but unabe to update that.
> I used function Set Element Text as
> Set Element Text common.xml ${incremented value} xpath=.//RollNo
> This function get passed successfully but that value cant get updated
The reason the above doesn't work is that Set Element Text doesn't
modify the original XML file. It returns you the modified XML
structure, though, and you can then use Save XML to save it:
${xml} = Set Element Text common.xml ${incremented value}
xpath=.//RollNo
Save XML ${xml} common.xml
Notice that if you would give Set Element Text an already parsed XML
strucutre, it would modify it in place in addition to returning it. In
other words, this would also work:
${xml} = Parse XML common.xml
Set Element Text ${xml} ${incremented value} xpath=.//RollNo
Save XML ${xml} common.xml
This is by design but it clearly not too well documented. Hopefully
docs are a bit more clear after this commit:
https://github.com/robotframework/robotframework/commit/9d8c470d4431ad2ef8b52bf2a6f867e05ba0817d