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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.