drmohundro / SWXMLHash

Simple XML parsing in Swift
MIT License
1.4k stars 203 forks source link

feat: add parent to XMLElement #278

Open drmohundro opened 10 months ago

drmohundro commented 10 months ago

Initial draft for a parent property for XMLElement... to cover #277.

Also includes support for Swift 5.9.

Sample usage from the unit test:

    func testShouldBeAbleToGetParent() {
        XCTAssertNotNil(xml!["root"]["catalog"]["book"][1]["author"].element?.parent)
        XCTAssertEqual(xml!["root"]["catalog"]["book"][1]["author"].element?.parent?.name, "book")
        XCTAssertEqual(xml!["root"]["catalog"]["book"][1]["author"].element?.parent?.attribute(by: "id")?.text, "bk102")
    }
codecov[bot] commented 10 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (7226ebc) 74.06% compared to head (0b84d87) 77.90%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #278 +/- ## ========================================== + Coverage 74.06% 77.90% +3.84% ========================================== Files 36 36 Lines 1997 2195 +198 ========================================== + Hits 1479 1710 +231 + Misses 518 485 -33 ``` | [Files](https://app.codecov.io/gh/drmohundro/SWXMLHash/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+Mohundro) | Coverage Δ | | |---|---|---| | [Source/XMLAttribute.swift](https://app.codecov.io/gh/drmohundro/SWXMLHash/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+Mohundro#diff-U291cmNlL1hNTEF0dHJpYnV0ZS5zd2lmdA==) | `100.00% <ø> (ø)` | | | [Source/XMLElement.swift](https://app.codecov.io/gh/drmohundro/SWXMLHash/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+Mohundro#diff-U291cmNlL1hNTEVsZW1lbnQuc3dpZnQ=) | `96.61% <100.00%> (+0.11%)` | :arrow_up: | | [Tests/SWXMLHashTests/XMLParsingTests.swift](https://app.codecov.io/gh/drmohundro/SWXMLHash/pull/278?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+Mohundro#diff-VGVzdHMvU1dYTUxIYXNoVGVzdHMvWE1MUGFyc2luZ1Rlc3RzLnN3aWZ0) | `86.18% <100.00%> (+1.94%)` | :arrow_up: | ... and [12 files with indirect coverage changes](https://app.codecov.io/gh/drmohundro/SWXMLHash/pull/278/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=David+Mohundro)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.