def xmliter(obj, nodename):
 nodename_patt = re.escape(nodename)
 HEADER_START_RE = re.compile(('^(.*?)<\\s*%s(?:\\s|>)' % nodename_patt), re.S)
 HEADER_END_RE = re.compile(('<\\s*/%s\\s*>' % nodename_patt), re.S)
 text = _body_or_str(obj)
 header_start = re.search(HEADER_START_RE, text)
 header_start = (header_start.group(1).strip() if header_start else '')
 header_end = re_rsearch(HEADER_END_RE, text)
 header_end = (text[header_end[1]:].strip() if header_end else '')
 r = re.compile(('<%(np)s[\\s>].*?</%(np)s>' % {'np': nodename_patt}), re.DOTALL)
 for match in r.finditer(text):
  nodetext = ((header_start + match.group()) + header_end)
  (yield Selector(text=nodetext, type='xml').xpath(('//' + nodename))[0])

def xmliter ( obj , nodename ) : nodename_patt = re . escape ( nodename ) HEADER_START_RE = re . compile ( ( '^(.*?)<\\s*%s(?:\\s|>)' % nodename_patt ) , re . S ) HEADER_END_RE = re . compile ( ( '<\\s*/%s\\s*>' % nodename_patt ) , re . S ) text = _body_or_str ( obj ) header_start = re . search ( HEADER_START_RE , text ) header_start = ( header_start . group ( 1 ) . strip ( ) if header_start else '' ) header_end = re_rsearch ( HEADER_END_RE , text ) header_end = ( text [ header_end [ 1 ] : ] . strip ( ) if header_end else '' ) r = re . compile ( ( '<%(np)s[\\s>].*?</%(np)s>' % { 'np' : nodename_patt } ) , re . DOTALL ) for match in r . finditer ( text ) : nodetext = ( ( header_start + match . group ( ) ) + header_end ) ( yield Selector ( text = nodetext , type = 'xml' ) . xpath ( ( '//' + nodename ) ) [ 0 ] )
return a iterator of selectors over all nodes of a xml document .