xml namespaces & prefixes causing problems selecting nodes


In my app I am querying a service, which sends an xml response, and I am trying to parse it using the xml extension provided by OutSystems. I have run into a couple difficulties related to namespaces in the xml:

1. The beginning of the xml is shown below. I use XmlDocument_Load_v2() to load my xml into a DOM, and that completes without error. However, I then use XmlDocument_SelectNodes() and specify the xpath "feed/entry", but it returns an XmlNodeList with a length of 0. I have found that if I delete <xmlns="http://www.w3.org/2005/Atom"> from my xml before loading it, the list has 2 nodes, which is correct, and I can further query those nodes as expected. My first question is: Is there a way to load the xml without first modifying the namespace declaration?

2. When I try to specify an xpath to an element that contains the prefix <d:> or <m:>, the element is undefined, and then I can't query that object. For example, once I have selected the first entry element in the xpath feed/entry, I would like to specify an xpath similar to the one I specify below, and then get the value from the FieldOne element using XmlElement_GetInnerText(). Could someone help me figure out how to get the text contained by the FieldOne element?


Thank you for any help you can offer. By the way, I have been looking through the forums, and I found a similar question here. The only answer was to use the XML Records forge component, but I would prefer to not use that component because it requires putting the output into a structure that has the same hierarchy as the data you are trying to extract, but I only need a couple pieces of information from each feed/entry element, and I would like to return the data in a flat structure.

I am also attaching a text file that contains a full xml response.

Hi Ryan,

Perhaps, you want to consider using Regex? After all you have a text and a pattern.

This component allows you to test and make sure you have the right syntax as well as to see how to call it from OutSystems both server and client side.

I was able to extract what you want by using this pattern (?<=d:FieldOne (.*)>).*(?=</d:FieldOne>) but you can tune more to your use case.

Hope it helps.




I ultimately figured out how to solve my problem of not being able to create an xpath that references elements containing a prefix (such as m: or d: in my example above) that correspond to a namespace. When you reference one of these elements, instead of creating an xpath like this: 


the xpath needs to be structured like this:


Hope this helps someone else.