From dd6b4e38aa94e152c9a1193f37f4288b749be368 Mon Sep 17 00:00:00 2001 From: Nick Jennings Date: Mon, 25 Jan 2021 04:17:48 +0100 Subject: [PATCH] Mention XML string parse script --- packages/xml/README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/packages/xml/README.md b/packages/xml/README.md index d61f15a2b..49a764509 100644 --- a/packages/xml/README.md +++ b/packages/xml/README.md @@ -201,6 +201,16 @@ const body = message.getChild("body"); message.remove(body); ``` +## Parsing XML string + +To parse a string into an XML Element, there's a helper script included in the module. + +```js +const parse = require('@xmpp/xml/lib/parse'); +const ctx = parse('hello world'); +ctx.getChildText("body"); // hello world +``` + ## JSON You can embed JSON anywhere but it is recommended to use an appropriate semantic.