I read the XML file, deserialize a string for an XDocument. When displaying only the XDocument variable, it shows all the XML. When I’m going to filter to get the elements, for example:
xmlDoc is my variable XDocument,
xmlDoc.Element (“emit”). Element (“CNPJ”). Value the image error occurs.
When I run the image process, which is the example of the UiPath itself, the same error occurs.
Is the element you’re looking for in the XMLfiles.txt? I think the error occurs because it does not exist in the XMLfiles.txt. Thus, null value is returned. I downloaded the activity from UiPath and ran it - it works well. But when I changed the element to something I know does not exist in the XMLfiles.txt, I encountered the same error: “Object reference not set to an instance of the object”
Yes, I did the correct test now and it worked. The problem is in the XML that I need to work on. For some reason I can’t get the tag’s values from this XML. Here is a piece of it:
I think you have to include several for loops to get the tags under . I tried to use the XML you provided; I was getting the null error as well when I try to get the value of .
What I did was I added the following loops inside the initial loop in UiPath sample XAML:
Loop IEnumerable “node.document.DescendantNodes()”
If item.name.localname = “ide”, assign item.Descendants to variable then break
Else //do nothing
End Loop
Loop IEnumerable “item.Descendants”
If item.name.localname = “cNF”, assign item.value.toString to variable
End Loop
@Octavio_Bertolucci
Your XML has namespaces. thats why you get no returns in case you only use the local name for retrieval. Fortunately you will find some working examples for this type of XML here in forum ( do also a further search by your own)