Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can we configure simple-xml to let it ignore unknown nodes

When using simple-xml, is there a way to let it ignore the nodes it does not recognize?

like image 940
user496949 Avatar asked Oct 12 '22 13:10

user496949


1 Answers

Yes. If you annotate your class with @Root(strict=false) it will ignore any elements that are not mapped. See the documentation for additional details:

http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#loosemap

On a related note, you can also handle optional elements using @Element(required=false).

http://simple.sourceforge.net/download/stream/doc/tutorial/tutorial.php#optional

like image 91
Michael Doyle Avatar answered Oct 14 '22 10:10

Michael Doyle