2024 Jul 08 5:20 PM - edited 2024 Jul 08 5:22 PM
hi,
I have to read an attribute of the xml as a property, the namespace is also present.
the xml is like this:
<ns0:test>
<test2 ns1:testattribute="test">
</test2>
</ns0:test>
How do I read the "testattribute" attribute with xpath?
I tried:
/test/test2/@testattribute
but looking in trace, the property is empty and does not contain the value:
Thank you
Request clarification before answering.
I think you are looking for something like the following, otherwise you must qualify your namespaces in your XPath expression.
/*[local-name() = 'test']/test2/@*[local-name() = 'testattribute']
Regards,
Ryan Crosby
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi,
thank you for the reply.
I don't know the value of the attribute, can I make it dynamic?
I find this:
but since I don't know the value of the attribute, I don't know what to put in place of 'value'
hi, @Ryan-Crosby
the purpose is to take the value of the attribute. for example, in this case the attribute name is 'testattribute' and its value is 'test' (the value can change with each call).
I need to valorise the value of the attribute in a property (so in this case 'test') because then I have to use the property in the flow.
the attribute level is just like the example below (and namespaces are also present):
<ns0:test>
<tes2 ns1:testattribute="test">
</tes2>
</ns0:test>
@mark_fryu still don't know how you would make use of an unknown attribute in any flow. If you don't know what you are looking for, then how would you know when you've found it?
hi @Ryan-Crosby
the flow on integration suite receives a call via SOAP, the xml attribute can have different values.
For example, I can receive the following XML:
<ns0:test>
<tes2 ns1:testattribute="control">
</tes2>
</ns0:test>
Or I can receive the following XML:
<ns0:test>
<tes2 ns1:testattribute="invoice">
</tes2>
</ns0:test>
so I know the name of the attribute, but I don't know the value.
Let me know if I made myself understood
Thank you
hi @Ryan-Crosby
oh okay thanks, it worked!!
Can I ask you if you can tell me why we need to use the local-name() function?
Is there a site/blog where it explains the existence of all the functions that can be used?
A thousand thanks
@mark_fryu the * is to denote any namespace, otherwise you have to give the exact reference - e.g. ns0:test. The other option is *:test which I tested to confirm it also works. Personally I would opt for the use of local-name() because it looks cleaner to read vs. noticing the tiny asterisk character.
hi, @Ryan-Crosby
Hi, the purpose is to take the value of the attribute.
for example, in this case the attribute name is 'testattribute' and its value is 'test' (the value can change with each call).
I need to valorise the value of the attribute in a property (so in this case 'test') because then I have to use the property in the flow
the attribute level is just like the example below (and namespaces are also present):
<ns0:test>
<tes2 ns1:testattribute="test">
</tes2>
</ns0:test>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
| User | Count |
|---|---|
| 7 | |
| 5 | |
| 5 | |
| 3 | |
| 3 | |
| 3 | |
| 2 | |
| 2 | |
| 2 | |
| 2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.