@aaxis/fast-xml-parser 中文文档教程

发布于 3年前 浏览 56 项目主页 更新于 3年前

fast-xml-parser

Open Collective 的支持者Sponsors on Open Collective已知漏洞NPM 质量Travis ci 构建状态覆盖状态试试我

验证 XML,将 XML 解析为 JS 对象,或从 JS 对象构建 XML,无需基于 C/C++ 的库且无回调。

Stubmatic donate button

检查ThankYouBackers 我们的贡献者

Users

< /a>

此处查看所有已知用户的列表;

用户列表是从 Github 发布的列表中收集的,直接通过 mails/chat 收集,或者从其他资源中收集。 如果您觉得上面列表中您的名字有误,或者您不再是本图书馆的用户,您可以通知我们将其删除。 我们会尽快进行必要的更改。

Main Features

FXP logo

  • Validate XML data syntactically
  • Parse XML to JS Object
  • Build XML from JS Object
  • Works with node packages, in browser, and in CLI (press try me button above for demo)
  • Faster than any pure JS implementation.
  • It can handle big files (tested up to 100mb).
  • Controlled parsing using various options
  • XML Entities, HTML entities, and DOCTYPE entites are supported.
  • unpaired tags (Eg <br> in HTML), stop nodes (Eg <script> in HTML) are supported.
  • You can restore almost same XML from JSON
  • Supports comments
  • It can preserve Order of tags in JS object
  • You can control if a single tag should be parsed into array.
  • Supports parsing of PI (Processing Instruction) tags with XML declaration tags
  • And many more other features.

How to use

用作包依赖 项 $ npm install fast-xml-parser 或者 $ yarn add fast-xml-parser

用作系统命令 $ npm install fast-xml-parser -g

要在 webpage 上使用它,请从 CDN

示例

作为 CLI 命令

$ fxparser some.xml

在节点 js 项目

const { XMLParser, XMLBuilder, XMLValidator} = require("../src/fxp");

const parser = new XMLParser();
let jObj = parser.parse(XMLdata);

const builder = new XMLBuilder();
const xmlContent = builder.build(jObj);

中 在 HTML 页面中

<script src="path/to/fxparser.js"></script>
:
<script>
  const parser = new fxparser.XMLParser();
  parser.parse(xmlContent);
</script>

Documents

v3

v4

  1. GettingStarted.md
  2. XML Parser
  3. XML Builder
  4. XML Validator
  5. Entites
  6. HTML Document Parsing
  7. PI Tag processing

Performance

XML Parser

大文件

XML Builder

负数表示错误

Our other projects and research you must try

  • BigBit standard :
  • Single text encoding to replace UTF-8, UTF-16, UTF-32 and more with less memory.
  • Single Numeric datatype alternative of integer, float, double, long, decimal and more without precision loss.
  • Cytorus: Now be specific and flexible while running E2E tests.
  • Run tests only for a particular User Story
  • Run tests for a route or from a route
  • Customizable reporting
  • Central dashboard for better monitoring
  • Stubmatic : Create fake webservices, DynamoDB or S3 servers, Manage fake/mock stub data, Or fake any HTTP(s) call.

Supporters

Contributors

这个项目的存在要感谢所有贡献的人。 [贡献]。

Backers

谢谢大家我们的支持者! ??? [成为支持者]

Sponsors

[成为赞助商] 通过成为赞助商来支持这个项目。 您的徽标将显示在此处,并带有指向您网站的链接。 还请分享您的详细信息,以便我们在社交媒体上感谢您。

License

  • MIT License

捐赠 $5

fast-xml-parser

Backers on Open CollectiveSponsors on Open CollectiveKnown VulnerabilitiesNPM qualityTravis ci Build StatusCoverage StatusTry meNPM total downloads

Validate XML, Parse XML to JS Object, or Build XML from JS Object without C/C++ based libraries and no callback.

Stubmatic donate button

Check ThankYouBackers for our contributors

Users

Check the list of all known users here;

The list of users is collected either from the list published by Github, cummunicated directly through mails/chat , or from other resources. If you feel that your name in the above list is incorrectly published or you're not the user of this library anymore then you can inform us to remove it. We'll do the necessary changes ASAP.

Main Features

FXP logo

  • Validate XML data syntactically
  • Parse XML to JS Object
  • Build XML from JS Object
  • Works with node packages, in browser, and in CLI (press try me button above for demo)
  • Faster than any pure JS implementation.
  • It can handle big files (tested up to 100mb).
  • Controlled parsing using various options
  • XML Entities, HTML entities, and DOCTYPE entites are supported.
  • unpaired tags (Eg <br> in HTML), stop nodes (Eg <script> in HTML) are supported.
  • You can restore almost same XML from JSON
  • Supports comments
  • It can preserve Order of tags in JS object
  • You can control if a single tag should be parsed into array.
  • Supports parsing of PI (Processing Instruction) tags with XML declaration tags
  • And many more other features.

How to use

To use as package dependency $ npm install fast-xml-parser or $ yarn add fast-xml-parser

To use as system command $ npm install fast-xml-parser -g

To use it on a webpage include it from a CDN

Example

As CLI command

$ fxparser some.xml

In a node js project

const { XMLParser, XMLBuilder, XMLValidator} = require("../src/fxp");

const parser = new XMLParser();
let jObj = parser.parse(XMLdata);

const builder = new XMLBuilder();
const xmlContent = builder.build(jObj);

In a HTML page

<script src="path/to/fxparser.js"></script>
:
<script>
  const parser = new fxparser.XMLParser();
  parser.parse(xmlContent);
</script>

Documents

v3

v4

  1. GettingStarted.md
  2. XML Parser
  3. XML Builder
  4. XML Validator
  5. Entites
  6. HTML Document Parsing
  7. PI Tag processing

Performance

XML Parser

Large files

XML Builder

negative means error

Our other projects and research you must try

  • BigBit standard :
  • Single text encoding to replace UTF-8, UTF-16, UTF-32 and more with less memory.
  • Single Numeric datatype alternative of integer, float, double, long, decimal and more without precision loss.
  • Cytorus: Now be specific and flexible while running E2E tests.
  • Run tests only for a particular User Story
  • Run tests for a route or from a route
  • Customizable reporting
  • Central dashboard for better monitoring
  • Stubmatic : Create fake webservices, DynamoDB or S3 servers, Manage fake/mock stub data, Or fake any HTTP(s) call.

Supporters

Contributors

This project exists thanks to all the people who contribute. [Contribute].

Backers

Thank you to all our backers! ???? [Become a backer]

Sponsors

[Become a sponsor] Support this project by becoming a sponsor. Your logo will show up here with a link to your website. Please also share your detail so we can thankyou on SocialMedia.

License

  • MIT License

Donate $5

    我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
    原文