Skip to content
Advertisement

Split a nested XML string to get a string using parser

I have this string :

JavaScript

My goal is to extract Panneau de polystyrène expansé (PSE) ignifugé réalisant une fonction d’isolation thermique pour unnm² de surface en assurant la résistance thermique de R = 3.55 K.m².W-1. so the text between <run> and </run>

I did it with regular expression but it doesn’t work with some xml string so I tried with xml.etree.ElementTree but I didn’t succeed to access the sting nested in <run></run>

How can I extract this text using XML parser?

Advertisement

Answer

Here a simple way to get the data:

JavaScript

Result:

Panneau de polystyrène expansé (PSE) ignifugé réalisant une fonction d’isolation thermique pour un m² de surface en assurant la résistance thermique de R = 3.55 K.m².W-1.

If you run the code in a python interactive prompt, at the end you can use results:

JavaScript
User contributions licensed under: CC BY-SA
6 People found this is helpful
Advertisement