New Member.. anschust
New Member..
128 views

Using XPATH to query XML that contains a namespace definition

Hello,

 

we have got problems while using XPATH with a XML document that contains a name space.

Example:

 

 

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<flowInputParam xmlns="http://com.mycompany.prj/HPOO_flow_input_param">
   <action>test</action>
</flowInputParam>

 

XPATH using /flowInputParam/action

 

does not return a result.

 

However, if the xmls... attribute is omitted, then the XPATH returns the expected result.

 

Any ideas why XPATH does not work if xmlns... attribut is defined?

 

Many Thanks in Advance

 

 

 

 

 

Labels (1)
Tags (2)
0 Likes
1 Reply
Absent Member.. Sussan_Z_OO Absent Member..
Absent Member..

Re: Using XPATH to query XML that contains a namespace definition

Hello anschut,

 

I am Operations Orchestration representative, regarding your request please take a look the next information:

 

When you use the xmlns=" http://com.mycompany.prj/HPOO_flow_input_param" on the root element of your XML puts the root and its descendants in the http://com.mycompany.prj/HPOO_flow_input_param. This effectively means that all of the element names in your XML document are preceded by http://com.mycompany.prj/HPOO_flow_input_param. Therefore the elements stated in your XPath are not in the http://com.mycompany.prj/HPOO_flow_input_param namespace. Then, your XPath will not matches nothing.

 

 

Solutions:

Using xmlns:conf="URL" instead of “xmlns”,  the XPath will matches the element.

 

 

Example:

 

 

I hope this information help you, but if not doesn't hesitate to let me know and I will continue with my researches.

Kind Regards,

 

Sussan Zamora

HPOO

“Regards,
If you find this or any post useful to resolve the issue, please mark this thread as correct answer and other members can benefit with the information given
Sussan Zamora
SW Support Technical Consultant
San Jose, Costa Rica
hpe.com
Hewlett Packard Enterprise “
0 Likes
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.