Get XMl data


I need to get an information inside a XML file.

I did that:

i need to get the number in the field “chave”



As per the message box, you’re trying to get the count of “Chave”. Can you please remove count and try only with xmlout.Descendants(“Chave”).ToString.

this messsage appear:



As per the message you get the list of nodes not the value
Can you try like xmlout.descendants(“”)(0). value


Could you please try once with xmlout.Descendants(“chave”).Value.ToString.

Let me know if this works or not.

@venkat4u @singhonkar

I used this code: xmlout.Descendants(“chave”).value

and this message appear:

If i use this: xmlout.Descendants(“chave”).value.tostring

this message appear


Can you share your xml file


Sorry for the late reply. Can you please try the below command in the your message box and let me know if this works or not.

xmlout.Element(“cteProc”).Element(“CT e”).Element(“infCte”).Element(“infCT eNorm”).Element(“infDoc”).Element(“infNFe”).Element(“chave”).Value.ToString

Please cross check all of these tags names as screenshot resolution is not good.

hello, @singhonkar and @venkat4u

For this code: xmlout.Element(“cteProc”).Element(“CT e”).Element(“infCte”).Element(“infCT eNorm”).Element(“infDoc”).Element(“infNFe”).Element(“chave”).Value.ToString

this message appear:

In attach I left the XML file:
35190343500198000185570000003091261327667357.xml (7.5 KB)



Please try once with ExecuteXPath activity as the data which you want to retrieve is in nested state.

Refer to this post: Fetch XML node value (with condition on other node values) using Execute Xpath utility in UIPath - #14

hello @singhonkar and @venkat4u

i tried this:

and this messsage appear:

sorry for my late to answer…


This is due to the lack of specifying a namespace prefix in the source XML as such, when using XPath or traversing the DOM it doesn’t know how to reference the elements as the default namespace has no prefix.

Note: This is not specific to UiPath, but difference applications and languages deal with it in different ways.

You have a couple of options and ways to work around this depending on the influence you have on the original source.

  1. Provide a prefix for the namespace from the source and prefixing the nodes with the prefix

      <CTe xmlns="">
        <infCte versao="3.00" Id="CTe35190343500198000185570000003091261327667357">


      <CTe xmlns:someprefix="">
        <someprefix:infCte versao="3.00" Id="CTe35190343500198000185570000003091261327667357">
  2. Strip/Replace the xmlns pseudo-attribute from each of the elements where needed using String.Replace or Regex/Regex.Replace. Deserialize the XML and query with XMLDocument methods or XPath as needed.

  3. Use the local-name / namespace-uri references when building your XPath expression. IT can get a bit messy, but it’s flexible without needing to modify the source XML.


    Wrapping it in the fn:String() function and/or adjusting the query as needed.

  4. Register a NamespaceManager with the XmlDocument.NameTable for the defined namespace and provide a prefix to apply to the default space and use the XmlDocument or XDocument methods like you normally would turning the XPath query into something like


    For what little I’ve spent in this realm, this usually seems to be the correct approach (assuming you can’t influence the original source) to handling the default namespace with no prefix. I find it a bit cumbersome in UiPath and easier to go about it programmatically, so you’d probably find one of the other options easier and faster to work with.

I would recommend reading up more on XML Namespaces and XPath should you want to have a better understanding.

1 Like