You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/v4/2.XMLparseOptions.md
+80-9Lines changed: 80 additions & 9 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -280,24 +280,95 @@ FXP by default parse XMl entities if `processEntities: true`. You can set `htmlE
280
280
281
281
## ignoreAttributes
282
282
283
-
By default `ignoreAttributes` is set to `true`. It means, attributes are ignored by the parser. If you set any configuration related to attributes without setting `ignoreAttributes: false`, it is useless.
283
+
By default, `ignoreAttributes` is set to `true`. This means that attributes are ignored by the parser. If you set any configuration related to attributes without setting `ignoreAttributes: false`, it will not have any effect.
284
+
285
+
### Selective Attribute Ignoring
286
+
287
+
You can specify an array of strings, regular expressions, or a callback function to selectively ignore specific attributes during parsing or building.
288
+
289
+
### Example Input XML
290
+
291
+
```xml
292
+
<tag
293
+
ns:attr1="a1-value"
294
+
ns:attr2="a2-value"
295
+
ns2:attr3="a3-value"
296
+
ns2:attr4="a4-value">
297
+
value
298
+
</tag>
299
+
```
300
+
301
+
You can use the `ignoreAttributes` option in three different ways:
302
+
303
+
1.**Array of Strings**: Ignore specific attributes by name.
304
+
2.**Array of Regular Expressions**: Ignore attributes that match a pattern.
305
+
3.**Callback Function**: Ignore attributes based on custom logic.
306
+
307
+
### Example: Ignoring Attributes by Array of Strings
Copy file name to clipboardExpand all lines: docs/v4/3.XMLBuilder.md
+83-1Lines changed: 83 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -170,7 +170,89 @@ It is recommended to use `preserveOrder: true` when you're parsing XML to js obj
170
170
By default, parsed XML is single line XML string. By `format: true`, you can format it for better view.
171
171
172
172
## ignoreAttributes
173
-
Don't consider attributes while building XML. Other attributes related properties should be set to correctly identifying an attribute property.
173
+
174
+
By default, the `ignoreAttributes` option skips attributes while building XML. However, you can specify an array of strings, regular expressions, or a callback function to selectively ignore specific attributes during the building process.
175
+
176
+
### Selective Attribute Ignoring
177
+
178
+
The `ignoreAttributes` option supports:
179
+
180
+
1.**Array of Strings**: Ignore specific attributes by name while building XML.
181
+
2.**Array of Regular Expressions**: Ignore attributes that match a pattern while building XML.
182
+
3.**Callback Function**: Ignore attributes based on custom logic during the building process.
183
+
184
+
### Example Input JSON
185
+
186
+
```json
187
+
{
188
+
"tag": {
189
+
"$ns:attr1": "a1-value",
190
+
"$ns:attr2": "a2-value",
191
+
"$ns2:attr3": "a3-value",
192
+
"$ns2:attr4": "a4-value",
193
+
"tag2": {
194
+
"$ns:attr1": "a1-value",
195
+
"$ns:attr2": "a2-value",
196
+
"$ns2:attr3": "a3-value",
197
+
"$ns2:attr4": "a4-value"
198
+
}
199
+
}
200
+
}
201
+
```
202
+
203
+
### Example: Ignoring Attributes by Array of Strings
0 commit comments