xml Regex matching the whole xml file -


i need regular expression given following xml, give me products (productos) have 'bebidas' category (categoria), , have in sublime text, have option use regular expression (no dedicated xml parser allowed):

xml file www.ethgf.com/electricos.xml

i have problem when use (?s)<producto>(.+?bebidas.+?)<\/producto> because highlights xml (the first 'producto' tag through last tag closure).

since question selecting whole <product> nodes, can use following regex:

(?s)<product>(?:\s*<(\w+)>[^<]*?<\/\1>\s*)*?\s*<category>drinks<\/category>(?:\s*<(\w+)>[^<]*?<\/\2>\s*)*?\s*<\/product>

it highlight <product> nodes contain drinks category, if nodes not following strict order:

enter image description here


Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -