{"id":1742,"url":"https://github.com/honghaoz/Ji","last_synced_at":"2025-08-02T04:32:26.398Z","repository":{"id":56916919,"uuid":"39320581","full_name":"honghaoz/Ji","owner":"honghaoz","description":"Ji (戟) is an XML/HTML parser for Swift","archived":true,"fork":false,"pushed_at":"2020-01-15T23:04:06.000Z","size":509,"stargazers_count":822,"open_issues_count":11,"forks_count":65,"subscribers_count":18,"default_branch":"master","last_synced_at":"2025-07-14T17:46:25.988Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Swift","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/honghaoz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-07-19T03:07:38.000Z","updated_at":"2025-07-01T15:30:41.000Z","dependencies_parsed_at":"2022-08-20T21:20:26.017Z","dependency_job_id":null,"html_url":"https://github.com/honghaoz/Ji","commit_stats":null,"previous_names":[],"tags_count":13,"template":false,"template_full_name":null,"purl":"pkg:github/honghaoz/Ji","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honghaoz%2FJi","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honghaoz%2FJi/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honghaoz%2FJi/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honghaoz%2FJi/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/honghaoz","download_url":"https://codeload.github.com/honghaoz/Ji/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/honghaoz%2FJi/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":268334617,"owners_count":24233793,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-08-02T02:00:12.353Z","response_time":74,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-01-05T20:15:54.721Z","updated_at":"2025-08-02T04:32:26.130Z","avatar_url":"https://github.com/honghaoz.png","language":"Swift","funding_links":[],"categories":["Parsing","Libs","Swift","Network [🔝](#readme)"],"sub_categories":["XML \u0026 HTML","Network","Other free courses","Data Management"],"readme":"\u003ch3 align=\"center\"\u003e\n    \u003cimg src=\"Ji.png\" width=220 alt=\"Ji: a Swift XML/HTML parser\" /\u003e\n\u003c/h3\u003e\n\n# Ji 戟\n[![CI Status](https://travis-ci.org/honghaoz/Ji.svg?branch=master)](https://travis-ci.org/honghaoz/Ji)\n[![CocoaPods Version](https://img.shields.io/cocoapods/v/Ji.svg?style=flat)](http://cocoapods.org/pods/Ji)\n[![Carthage Compatible](https://img.shields.io/badge/Carthage-compatible-0473B3.svg?style=flat)](https://github.com/Carthage/Carthage)\n[![License](https://img.shields.io/cocoapods/l/Ji.svg?style=flat)](http://cocoapods.org/pods/Ji)\n[![Platform](https://img.shields.io/cocoapods/p/Ji.svg?style=flat)](http://cocoapods.org/pods/Ji)\n\nJi (戟) is a Swift wrapper on libxml2 for parsing XML/HTML.\n\n## Features\n- [x] Build XML/HTML Tree and Navigate.\n- [x] XPath Query Supported.\n- [x] Comprehensive Unit Test Coverage.\n- [x] Support Swift Package Manager (SPM). Linux compatible.\n\n## Requirements\n\n- iOS 8.0+ / Mac OS X 10.9+ / watchOS 2.0+ / tvOS 9.0+\n- Xcode 8.0+\n\n## Installation\n\n### [CocoaPods](http://cocoapods.org)\n\nTo integrate **Ji** into your Xcode project using CocoaPods, specify it in your `Podfile`:\n\n```ruby\nuse_frameworks!\n\npod 'Ji', '~\u003e 5.0.0'\n```\n\nThen, run the following command:\n\n```bash\n$ pod install\n```\n\n### [Carthage](http://github.com/Carthage/Carthage)\n\nTo integrate `Ji` into your Xcode project using Carthage, specify it in your `Cartfile`:\n\n```ogdl\ngithub \"honghaoz/Ji\" ~\u003e 5.0.0\n```\n\n### [Swift Package Manager (SPM)](https://swift.org/package-manager)\n\n#### Prerequisites\n- OSX\n\n```bash\nbrew install libxml2\nbrew link --force libxml2\n```\n\n- Linux\n```bash\n$ sudo apt-get install libxml2-dev\n```\n\n#### Update `Package.swift`\nTo integrate `Ji` in your project, add the proper description to your `Package.swift` file:\n```swift\n// swift-tools-version:5.0\nimport PackageDescription\n\nlet package = Package(\n    name: \"YOUR_PROJECT_NAME\",\n    dependencies: [\n        .package(url: \"https://github.com/honghaoz/Ji.git\", from: \"5.0.0\")\n    ],\n    targets: [\n        .target(\n            name: \"YOUR_TARGET_NAME\",\n            dependencies: [\"Ji\"]\n        ),\n        ...\n    ]\n)\n```\n\n### Manually\n\nIf you prefer not to use a dependency manager, you can integrate Ji into your project manually.\n\n- Add sources into your project:\n  - Drag `Ji.swift`, `JiHelper.swift` and `JiNode.swift` in [**Sources/Ji**](https://github.com/honghaoz/Ji/tree/master/Sources/Ji) folder into your project.\n  - Drag [**Sources/Clibxml2**](https://github.com/honghaoz/Ji/tree/master/Sources/Clibxml2) folder into your project.\n\n- Configure your project:\n    - Open project, select the target, under **Build Settings**, in **Header Search Paths**, add `$(SDKROOT)/usr/include/libxml2`\n    - Under **Build Settings**, in **Import Paths**, add `$(SRCROOT)/Clibxml2` (Make sure this is the path to the `Clibxml2` folder)\n\n## Usage\n\n\u003e If you are using CocoaPods to integrate Ji. Import Ji first:\n\u003e ```swift\n\u003e import Ji\n\u003e ```\n\n- Init with `URL`:\n```swift\nlet jiDoc = Ji(htmlURL: URL(string: \"http://www.apple.com/support\")!)\nlet titleNode = jiDoc?.xPath(\"//head/title\")?.first\nprint(\"title: \\(String(describing: titleNode?.content))\") // title: Optional(\"Official Apple Support\")\n```\n\n- Init with `String`:\n```swift\nlet xmlString = \"\u003c?xml version='1.0' encoding='UTF-8'?\u003e\u003cnote\u003e\u003cto\u003eTove\u003c/to\u003e\u003cfrom\u003eJani\u003c/from\u003e\u003cheading\u003eReminder\u003c/heading\u003e\u003cbody\u003eDon't forget me this weekend!\u003c/body\u003e\u003c/note\u003e\"\nlet jiDoc = Ji(xmlString: xmlString)\nlet bodyNode = jiDoc?.rootNode?.firstChildWithName(\"body\")\nprint(\"body: \\(String(describing: bodyNode?.content))\") // body: Optional(\"Don\\'t forget me this weekend!\")\n```\n\n- Init with `Data`:\n```swift\nlet googleIndexData = try? Data(contentsOf: URL(string: \"http://www.google.com\")!)\nif let googleIndexData = googleIndexData {\n    let jiDoc = Ji(htmlData: googleIndexData)!\n    let htmlNode = jiDoc.rootNode!\n    print(\"html tagName: \\(String(describing: htmlNode.tagName))\") // html tagName: Optional(\"html\")\n\n    let aNodes = jiDoc.xPath(\"//body//a\")\n    if let firstANode = aNodes?.first {\n        print(\"first a node tagName: \\(String(describing: firstANode.name))\") // first a node tagName: Optional(\"a\")\n        let href = firstANode[\"href\"]\n        print(\"first a node href: \\(String(describing: href))\") // first a node href: Optional(\"http://www.google.ca/imghp?hl=en\u0026tab=wi\")\n    }\n} else {\n    print(\"google.com is inaccessible\")\n}\n\nlet 戟文档 = 戟(htmlURL: URL(string: \"https://cocoapods.org/pods/Ji\")!)\nlet attribution = 戟文档?.xPath(\"//ul[@class='attribution']\")?.first\nprint(\"作者(Author): \\(String(describing: attribution?.content))\") // 作者(Author): Optional(\"ByHonghao Zhang\")\n```\n\n## License\n\nThe MIT License (MIT)\n\nCopyright (c) 2019 Honghao Zhang (张宏昊)\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhonghaoz%2FJi","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhonghaoz%2FJi","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhonghaoz%2FJi/lists"}