reference Rule options

xml_children_ordered

Value
true or false
Default
true
See also
xml_singleton_loose_matching

The children of an element in an XML pattern match children in the same order. With xml_children_ordered: false, they match in any order.

Examples

Children in a different order

The rule list turns the option off.

lists.yaml
rules:  - id: list-default    pattern: <list><a/><b/></list>    message: list with a and b    languages: [xml]    severity: INFO  - id: list    pattern: <list><a/><b/></list>    message: list with a and b    languages: [xml]    severity: INFO    options:      xml_children_ordered: false
lists.xml
<root><!-- ruleid: list-default, list --><list><a/><b/></list><!-- ruleid: list --><list><b/><a/></list></root>
Command and result
$ opengrep test .
2/2: ✓ All tests passed
No tests for fixes found.