Flowdock
each( xpath=nil, &block) public

Iterates through all of the child Elements, optionally filtering them by a given XPath

xpath

optional. If supplied, this is a String XPath, and is used to filter the children, so that only matching children are yielded. Note that XPaths are automatically filtered for Elements, so that non-Element children will not be yielded

doc = Document.new ‘<a><c/><d/>sean<c/><d/>’ doc.root.each {|e|p e} #-> Yields b, c, d, b, c, d elements doc.root.each(‘b’) {|e|p e} #-> Yields b, b elements doc.root.each(‘child::node()’) {|e|p e} #-> Yields <b/>, <c/>, <d/>, <b/>, <c/>, <d/> XPath.each(doc.root, ‘child::node()’, &block) #-> Yields <b/>, <c/>, <d/>, sean, <b/>, <c/>, <d/>

Show source
Register or log in to add new notes.