Xml nodes can't be added as variables

Hey guys!

Recently i’ve started project and have a task:

I have a folder where xml files will be stored with dynamic names.
Each of files has different nodes.
Bot have to read each xml file from a folder, define nodes and create variables for specific nodes which i will set.
The point is i’ve tested it with 2 nodes and 2 variables and it worked fine. But when i defined more variables now i see error during debug process.

Error code: “Assign: Object reference not set to an instance of an object”
what i have:
Type of nodes variables: String
Type of xml output variable during Deserialize - xdocument. tried to change to string but it’s impossible
variable example:
variable_name=var_docxml.Element(“DECLAR”).Element(“DECLARBODY”).Element(“R1000G4”).Value.toString

XML example

<?xml version="1.0" encoding="windows-1251"?> 20068365 J09 001 8 0 1 28 10 12 5 2014 2810 1 03032020 MEDOC 31122014 TOВ "БАСФ Т.О.В." 20068365 8038200000 Товариство з обмеженою відповідальністю 240 Оптова торгівля хімічними продуктами 46.75 бульвар. Дружби Народiв , буд. 19, м. КИЇВ, 01042 5915596 1 31 грудня 2014 0 0 5 0 0 ...

I can’t understand where is a problem, cause it worked before.
Could you help me with an advice please?

Thanks!

@Eugene_Naumenko
A quick guess is that var_docxml.Element(“DECLAR”).Element(“DECLARBODY”).Element(“R1000G4”) is null. Does mean: the element is Not retrieved. So .Value.toString Producers the nullreference exception

You can check by part wise retrieval the path e.g Debugger, watch while Debugging or logging. So you can identify where the retrieval Breaks.

The posted XML Sample Looks a little Bit away from valid XML.maybe you have Not used the Code formattinh Option while writing the Post. Maybe you can Upload the XML itself

1 Like

HI @ppr!

I couldn’t attach xml files to my posts cause of rules of the forum (i am a new user).
Here is the link for the project including 2 xml files.
https://drive.google.com/open?id=1aQAV2Fiaqg8I9dkh2DOp_Ndr23hEvbHO
Interesting thing:
If i put message command after a variable, for example R1000G4, then it will show result during test run, but neverethelss give me the error in the end of sequence and will not proceed to the next step.
Very strange behavoir…