https://github.com/rubenfer/lightxmlparser
Parse XML files using Swift
https://github.com/rubenfer/lightxmlparser
swift xml xml-parser
Last synced: about 1 year ago
JSON representation
Parse XML files using Swift
- Host: GitHub
- URL: https://github.com/rubenfer/lightxmlparser
- Owner: Rubenfer
- Created: 2020-01-21T11:03:12.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-02-08T09:32:47.000Z (over 6 years ago)
- Last Synced: 2025-02-12T04:17:54.519Z (over 1 year ago)
- Topics: swift, xml, xml-parser
- Language: Swift
- Homepage:
- Size: 6.84 KB
- Stars: 2
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# LightXMLParser
LightXMLParser is a light-weight Swift package allows you to parse XML files.
## Installation
Add LightXMLParser to your project using SPM.
## Usage
To parse XML files using LightXMLParser you need to import the package.
`import LightXMLParser`
Then you can use it as simple as you create an XML object passing the content of XML as Data.
`let xml = XML(data: myXMLData)`
Each XML object has name, attributes and value.
An example XML file could be:
```xml
Value for tag 1.
```
For this example, you can get the following:
```swift
let xmlName = xml.name // xml
let tag1 = xml.children[0]
let tag1Name = tag1.name // tag1
let tag1Value = tag1.value // Value for tag 1.
let tag1Attributes = tag1.attributes
let tag1Attribute = tag1Attributes["attribute"] // attr-value
```
## Credits
[SwiftyXML](https://github.com/chenyunguiMilook/SwiftyXML)