Processing XML with Regular Expressions : XML Parse « XML « Python






Processing XML with Regular Expressions

 

import sys, re

pat = r'<title>(.*?)</title>'
data = open(sys.argv[1]).read()

m = re.search(pat,data)
if m:
   print m.group(1)

   
  








Related examples in the same category

1.Extracting the Ingredients from a Recipe with Regular Expressions
2.Simple XML Document Analysis
3.Parsing XML from Local Files and Remote URLsParsing XML from Local Files and Remote URLs
4.Parsing XML from a URL
5.Parsing XML from StringsParsing XML from Strings
6.Parsing XML: Loading an XML Document