diff --git a/docs/v4/2.XMLparseOptions.md b/docs/v4/2.XMLparseOptions.md index 338b6795..5616b7e6 100644 --- a/docs/v4/2.XMLparseOptions.md +++ b/docs/v4/2.XMLparseOptions.md @@ -62,6 +62,68 @@ Output ## alwaysCreateTextNode +FXP creates text node always when `preserveOrder: true`. Otherwise, it creates a property with the tag name and assign the value directly. + +You can force FXP to render a tag with textnode using this option. + +Eg +```js +const xmlData = ` + + wow + + wow again + unlimited + + wow phir se + `; + +const options = { + ignoreAttributes: false, + // alwaysCreateTextNode: true +}; +const parser = new XMLParser(options); +const output = parser.parse(xmlDataStr); +``` +Output when `alwaysCreateTextNode: false` +```json +{ + "root": { + "a": [ + "wow", + { + "c": "unlimited", + "#text": "wow again" + } + ], + "b": "wow phir se", + "@_a": "nice" + } +} +``` +Output when `alwaysCreateTextNode: true` +```json +{ + "root": { + "a": [ + { + "#text": "wow" + }, + { + "c": { + "#text": "unlimited" + }, + "#text": "wow again" + } + ], + "b": { + "#text": "wow phir se" + }, + "@_a": "nice" + } +} +``` + ## attributesGroupName To group all the attributes of a tag under given property name. @@ -590,66 +652,26 @@ Output } ``` -FXP creates text node always when `preserveOrder: true`. Otherwise, it creates a property with the tag name and assign the value directly. - -You can force FXP to render a tag with textnode using this option. +You can also mention a tag which should not be processed irrespective of their path. Eg. `
` or `