I have the following XML :
<sample>
<Message number="2">
<Title>Program pointer has been reset</Title>
<Description>
The program pointer of task
<arg format="%s" ordinal="3" />
has been reset.
</Description>
</Message>
</sample>
I’m trying to get the decription text with arg attribute values. Something like "The program pointer of task %s 3 has been reset."
and my attempt looked something like
'/sample//Message[@number = $mId]/Description'
but that didnt work.
With XPath 2.0 or XQuery 1.0 you could use
string-join(/sample//Message[@number = 2]/Description/(text() | */@*), ''). I am not sure whether Python gives you access to an XPath 2.0 or XQuery 1.0 library.