XDocument with namespace

Hello -
I have a rest webservice that returns ODATA in XML. I am able to put the XML it returns into an XDocument but all attempts to query the content fail.

I think it is because the XML contains namespaces. I followed the online guidance for XML and proved that I can get at the content of the XDocument if I manually edit out all of the namespace references.

Where am I going wrong please?

Here is a fragment form the start of the XML (if have edited the namespace links to comply with the forum rules)

<?xml version="1.0" encoding="utf-8" ?>

< feed xml:base=“…staging.ondemand.xxxxxxx.eu/nnnnnnn/odata/” xmlns=“…www.w3.org/2005/Atom” xmlns:d=“…schemas.microsoft.com/ado/2007/08/dataservices” xmlns:m=“…schemas.microsoft.com/ado/2007/08/dataservices/metadata” >
<id>…staging.ondemand.xxxxx.eu/nnnnnnn/odata/Participants(yyyy)/Results/</id>
<title type=“text”>Results</title>
<updated>2018-11-13T11:22:20Z</updated>
<link rel=“self” title=“Results” href=“Results” />
<category…

What activities are you using? What is the error you’re receiving?

Have you tried using a namespace manager? If not, please check the sample workflow in this post: Reading XML Attribute out of Uipath Xaml file - #2 by Mateus_Cruz

thanks for the response. I used DeserializeXML to create the XDocument and then a simple writeline to try to show the value of one of the XML elements.
I then tried XPath to query the XDocument.

In both cases the writeline activity throws and error that I am trying to access an object that does not exists. When I take out the namespace items it works fine.

I have looked for a namespace manager but could not find anything. I looked at the “imports” tab but that seems to relate to namespaces for packages.

Hi @pfNFUM.

I’m not saying this is the ideal solution because looks like you have valid namespaces but If it worked for you by ignoring the namespaces, here’s an option. I have an API that returns an XML file with namespaces that don’t resolve. Here’s a clip.

<Items xmlns:d2p1="http://schemas.datacontract.org/2004/07/ImageRight.Api.Models.Tasks">
- <d2p1:TaskModel>
    <d2p1:AssignedTo xmlns:d4p1="http://schemas.datacontract.org/2004/07/ImageRight.Api.Models.Security" i:nil="true" /> 
-   <d2p1:AvailableDate xmlns:d4p1="http://schemas.datacontract.org/2004/07/System">
      <d4p1:DateTime>2018-11-01T16:07:57.033Z</d4p1:DateTime> 
      <d4p1:OffsetMinutes>0</d4p1:OffsetMinutes> 
    <d2p1:ErrorCode>None</d2p1:ErrorCode> 
    <d2p1:ErrorMessage /> 
    <d2p1:FileAttributes xmlns:d4p1="http://schemas.datacontract.org/2004/07/ImageRight.Api.Models.Attributes" i:nil="true" /> 
    <d2p1:FileId>76256584</d2p1:FileId> 
    <d2p1:FileName /> 
    <d2p1:FileNumber>~ER2289792</d2p1:FileNumber> 
    <d2p1:FileTypeId>3700</d2p1:FileTypeId> 
    <d2p1:FlowId>6407088</d2p1:FlowId> 
    <d2p1:FlowName>Commercial Technician</d2p1:FlowName> 
    <d2p1:FolderAttributes xmlns:d4p1="http://schemas.datacontract

In order for me to get the FileId from above, I have to use local-name() like:

xmlRootNode.SelectSingleNode("Items/*[local-name()='TaskModel'][*[local-name()='FileNumber']='" & Quote & "']/*[local-name()='FileId']").InnerXml

Not sure if that will help you but here is more information on that subject