regex - How to write a regular expression to get text inside XML tags? -


i trying write regular expression return text inside xml tags. instance if had file format

<name>joe blog</name> <email>abc@sample.com</email> <address>123 sample st</address> 

how extract text address field?

any appreciated. thanks,

this expression capture address value

<address>(.*?)<\/address>

enter image description here

and place first capture group

example

sample text

<name>joe blog</name> <email>abc@sample.com</email> <address>123 sample st</address> 

matches

[0][0] = <address>123 sample st</address> [0][1] = 123 sample st 

however

most langages have html parsing tool, example in php using:

$dom = new domdocument(); $dom->loadhtml($your_html_here); $addresses= $dom->getelementsbytagname('address'); foreach($addresses $address) {     $address = $address->innertext;     // } 

Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

html - Unable to style the color of bullets in a list -

c# - must be a non-abstract type with a public parameterless constructor in redis -