Latest0.2.1
Homepagehttps://github.com/artemyarulin/react-native-xml
LicenseMIT
Platformsios 7.0, requires ARC
DependenciesGDataXML-HTML, React
Authors

React native compatable XML/HTML parser with XPath support

Usage

let xml = require('react-native').NativeModules.RNMXml
xml.queryXml('<doc a="V1">V2</doc>',
            ['/doc/@a', '/doc'],
            results => results.map(nodes => console.log(nodes[0])))
// Output:
//  V1
//  V2

queryXml(xmlString,queries) -> results

queryHtml(htmlString,queries) -> results

  • xmlString|htmlString – xml or html string
  • queries – array of xpath strings which would be executed against xml string
  • results – array of results such as queries.length == results.length. Each result is an array as well
let xml = require('react-native').NativeModules.RNMXml
xml.queryHtml('<html><div>a</div><div>b</div></html>',
             ['/html/body/div'],
             results => console.log(results[0]))
//Output: ['a','b']

parseString(string,isHtml) -> parsedTree

Where parsedTree is a dictionary (inspired by Clojure data.xml) with a structure:

{"tag":"tagName",
 "attrs:{"attrName":"attrValue"},
 "content":[either text content or the same structure for each childs]}

See tests for more information

Installation

Using Cocoapods:

pod 'react-native-xml', '0.2.1'

Latest podspec

{
    "name": "react-native-xml",
    "version": "0.2.1",
    "summary": "react native xml module with xpath support",
    "description": "Provides you a function to parse and search inside XML using XPath and JavaScript",
    "homepage": "https://github.com/artemyarulin/react-native-xml",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Artem Yarulin": "[email protected]"
    },
    "platforms": {
        "ios": "7.0"
    },
    "source": {
        "git": "https://github.com/artemyarulin/react-native-xml.git",
        "tag": "0.2.1"
    },
    "source_files": [
        "rnxml/rnxml/RNMXml.{h,m}"
    ],
    "public_header_files": "rnxml/rnxml/RNMXml.h",
    "requires_arc": true,
    "dependencies": {
        "GDataXML-HTML": [
            "1.3.0"
        ],
        "React": [
            "> 0.10.0"
        ]
    },
    "libraries": "xml2",
    "xcconfig": {
        "HEADER_SEARCH_PATHS": "$(SDKROOT)/usr/include/libxml2",
        "CLANG_ALLOW_NON_MODULAR_INCLUDES_IN_FRAMEWORK_MODULES": "YES"
    }
}

Pin It on Pinterest

Share This