Object reference not set to an instance of object error while processing xml file


Hello Team,

After deserializing the XML file I printed the whole data in a message box next to it I used write line activity. At write line activity it was showing an “Object reference not set to an instance of an object error”. Here is the attached file for reference. samplexaml.zip (6.3 KB)
Could anyone suggest, please


Your workflow looks good except that in case of xmls like any other tool the processor requires the namespace of the element to identify the correct element.

What you need to do.

  1. Create a variable ns of type XNamespace and set it default value to “http://www.portalfiscal.inf.br/nfe” which is your xmls default namespace
  2. In the write line where you are using .Element(“nfeProc”) you need to actually use .Element(ns+“nfeProc”)… like this for all your element.

Your writeline:


Thank you Nadim. Its working. May I know why namespaces required here as if I am not much aware of XML


Let me try and brief it out.

XML elements in a file need to be uniquely identified to avoid issues when you have same type of elements but they differ in usage (say ID of SAP and ID of Oracle. Both are same elements but belong to different classes/instances).
To do that there is a standard of using namespaces.
Namespaces can be single(when you do just xmlns) like in your case or many(when you use prefix xmlns:ns1).

So when you are using the .Element structure you are basically the processor that this is the path(xpath or xml-path) to the element that i want. nfeProc/NFe/infNFe/ide Its like a folder structure.

Now that there is a namespace for your elements that is defined in the parent element you will need to prefix that for the elements otherwise it will not be able to identify it and thus gives you the error “Object reference not set to an instance of an object error” because its empty.

Please close this thread marking the answer as a solution to this thread.


Thanks, Nadim. I have another small doubt regarding queues and transactions. I am able to retrieve the single item from Get Transaction Item activity (item.Specificcontent(“fieldname”). Can I do the same thing using Get Queues item activity if so could you plz let me know what is the command to get the item.


Actually When you will use GetQueuItems you will get the list of items that you want to extract and then you can iterate through the and get the required data out of each.

Detailed info can be found here:

Example of how to use this activity is here: