0

Hi Everyone,

Do you know how i can get the values using Regular Expression between the opening and closing tags of xml files? I need to process xml files using python and i just need to get the values between tags.
For example:

<name value>my name is </name value>

i just need to get the value my name is using regular expression.
can someone help me with this?

thanks!

4
Contributors
4
Replies
7
Views
7 Years
Discussion Span
Last Post by Gribouillis
0
import re

target = '<name value>my name is</name value>'
mobj = re.search('<.*>(.*)</.*>', target)
print mobj.groups()[0]
0

hi cghtkh!

thanks for your answer!

import re

target = '<name value>my name is</name value>'
mobj = re.search('<.*>(.*)</.*>', target)
print mobj.groups()[0]
0

Quote from stack overflow:

"asking regexes to parse arbitrary HTML is like asking Paris Hilton to write an operating system"

so it may not be the right tool... (Not meaning that I could write an OS either).

Edited by Gribouillis: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.