Skip to content

Commit c7cd744

Browse files
committed
Add 4.4.0 podspec, updated CHANGELOG
1 parent 0b18f5b commit c7cd744

File tree

3 files changed

+49
-1
lines changed

3 files changed

+49
-1
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
## v4.4.0 (February 4, 2018)
2+
3+
* Added `filter` support (via
4+
[#171](https://github.com/drmohundro/SWXMLHash/pull/174) and
5+
[#167](https://github.com/drmohundro/SWXMLHash/issues/170))
6+
17
## v4.3.6 (January 21, 2018)
28

39
* Fixed CDATA parsing in Linux (via

README.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -313,6 +313,48 @@ func enumerate(indexer: XMLIndexer) {
313313
enumerate(indexer: xml)
314314
```
315315

316+
### Filtering elements
317+
318+
Given:
319+
320+
```xml
321+
<root>
322+
<catalog>
323+
<book id=\"bk101\">
324+
<author>Gambardella, Matthew</author>
325+
<title>XML Developer's Guide</title>
326+
<genre>Computer</genre><price>44.95</price>
327+
<publish_date>2000-10-01</publish_date>
328+
</book>
329+
<book id=\"bk102\">
330+
<author>Ralls, Kim</author>
331+
<title>Midnight Rain</title>
332+
<genre>Fantasy</genre>
333+
<price>5.95</price>
334+
<publish_date>2000-12-16</publish_date>
335+
</book>
336+
<book id=\"bk103\">
337+
<author>Corets, Eva</author>
338+
<title>Maeve Ascendant</title>
339+
<genre>Fantasy</genre>
340+
<price>5.95</price>
341+
<publish_date>2000-11-17</publish_date>
342+
</book>
343+
</catalog>
344+
</root>
345+
```
346+
347+
The following will return return "Midnight Rain". Filtering can be by any part
348+
of the `XMLElement` class or by index as well.
349+
350+
```swift
351+
let subIndexer = xml!["root"]["catalog"]["book"]
352+
.filter { elem, _ in elem.attribute(by: "id")!.text == "bk102" }
353+
.filter { _, index in index >= 1 && index <= 3 }
354+
355+
print(subIndexer[0].element?.text)
356+
```
357+
316358
### Error Handling
317359

318360
Using Swift 2.0's new error handling feature:

SWXMLHash.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'SWXMLHash'
3-
s.version = '4.3.6'
3+
s.version = '4.4.0'
44
s.summary = 'Simple XML parsing in Swift'
55
s.homepage = 'https://github.com/drmohundro/SWXMLHash'
66
s.license = { type: 'MIT' }

0 commit comments

Comments
 (0)