Changes between Version 6 and Version 7 of TutXmlPath
- Timestamp:
- 03/28/09 04:08:04 (15 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
TutXmlPath
v6 v7 106 106 import tango.io.device.File; 107 107 import tango.io.Stdout; 108 import tango.text.Util;108 import Util = tango.text.Util; 109 109 import tango.text.xml.Document; 110 110 117 117 doc.parse(xml); 118 118 119 // a custom filter 120 bool test(doc.Node node) 121 { 122 auto attr = node.attributes.name(null, "id"); 123 return attr && Util.contains(attr.value, 'B'); 124 } 125 119 126 // get the root element 120 127 auto root = doc.elements; 121 128 122 129 // query the doc for all country elements with an id attribute that contains a 'B' 123 auto result = root.query.descendant("country").filter((doc.Node node) { 124 return contains!(char)(node.attributes.name(null, "id").value, 'B'); 125 }); 130 auto result = root.query.descendant("country").filter(&test); 126 131 127 132 foreach (e; result) {