xpath_selector_xml_parser 3.0.1 copy "xpath_selector_xml_parser: ^3.0.1" to clipboard
xpath_selector_xml_parser: ^3.0.1 copied to clipboard

A xml parser implementation with xml for xpath_selector, xpath_selector is required.

xpath_selector_xml_parser #

English | 简体中文

Usage #

There are three ways to create xpath queries:

  1. Use the queryXPath method directly on the html Node
  2. Use XmlXpath.node ([XmlNode]) to create a query and then use the query method to perform the query
  3. Use XmlXpath.html ([XmlString]) to parse the xml, and then use query to query

Example #

import 'package:xml/xml.dart';
import 'package:xpath_selector_xml_parser/xpath_selector_xml_parser.dart';

final input = '''
<bookstore xmlns:h="https://test.z31.ink" xmlns:t="https://test.z31.ink/sub">
    <book category="children">
        <title lang="en">Harry Potter</title>
        <author>J K. Rowling</author>
        <year>2005</year>
        <price>29.99</price>
    </book>
    <book category="cooking">
        <title lang="en">Everyday Italian</title>
        <author>Giada De Laurentiis</author>
        <year>2005</year>
        <price>30.00</price>
    </book>
    <book category="web" cover="paperback">
        <title lang="en">Learning XML</title>
        <author>Erik T. Ray</author>
        <year>2003</year>
        <price>39.95</price>
    </book>
    <book category="web">
        <title lang="en">XQuery Kick Start</title>
        <author>James McGovern</author>
        <author>Per Bothner</author>
        <author>Kurt Cagle</author>
        <author>James Linn</author>
        <author>Vaidyanathan Nagarajan</author>
        <year>2003</year>
        <price>49.99</price>
    </book>
</bookstore>
''';

void main() {
  final xml1 = XmlDocument.parse(input);
  final xml2 = XmlXPath.node(xml1);
  final xml3 = XmlXPath.xml(input);

  print(xml1.queryXPath('//book'));
  print(xml2.query('//book/title'));
  print(xml3.query('//*[@lang="en"]'));
}

0
likes
150
pub points
71%
popularity

Publisher

verified publisherz31.ink

A xml parser implementation with xml for xpath_selector, xpath_selector is required.

Repository (GitHub)
View/report issues

Documentation

API reference

License

BSD-3-Clause (license)

Dependencies

xml, xpath_selector

More

Packages that depend on xpath_selector_xml_parser