Coder Social home page Coder Social logo

xml5ever's Introduction

xml5ever

Build Status http://www.apache.org/licenses/LICENSE-2.0 https://opensource.org/licenses/MIT Clippy Linting Result

API documentation

Warning: This library is alpha quality, so no guarantees are given.

This crate provides a push based XML parser library that trades well-formedness for error recovery.

xml5ever is based largely on html5ever parser, so if you have experience with html5ever you will be familiar with xml5ever.

The library is dual licensed under MIT and Apache license.

#Why you should use xml5ever

Main use case for this library is when XML is badly formatted, usually from bad XML templates. XML5 tries to handle most common errors, in a manner similar to HTML5.

When you should use it?

  • You aren't interested in well-formed documents.
  • You need to get some info from your data even if it has errors (although not all possible errors are handled).
  • You want to features like character references or xml namespaces.

When you shouldn't use it

  • You need to have your document validated.
  • You require DTD support.
  • You require an easy to use parser, with lots of extensions (e.g. XPath, XQuery).
  • You require a battle tested, industry proven solution.

#Installation

Add xml5ever as a dependency in your project manifest.

    [dependencies]
    xml5ever = "0.1.1"

And add crate declaration in your lib.rs

    extern crate xml5ever

#Getting started

Here is a very simple RcDom backed parser:

    let input = "<xml></xml>".to_tendril();

    // To parse XML into a tree form, we need a TreeSink
    // luckily xml5ever comes with a static RC backed tree represetation.
    let dom: RcDom = parse(std::iter::once(input), Default::default());

    // Do something with dom

The thing that does actual parsing is the parse function. It expects an iterator that can be converted into StrTendril, so you can use std::iter::once(input) or Some(input).into_iter() (where input is StrTendril like structure).

xml5ever's People

Contributors

bpowers avatar frewsxcv avatar mbrubeck avatar simonsapin avatar ygg01 avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.