I have made an api with xml based request for my website.
but sometimes, some customers send me an invalid xml and I want to return a good response.
how can I validate xml?
edited:
Ok, I think I asked wrong question, I want to validate nodes and if some nodes missing then I return best response.
I used to validate this with php and I have to check every nodes. but this way is very hard to modify.
it is my xml example:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<mashhadhost>
    <create>
        <name>example.ir</name>
        <period>60</period>
        <ns>
            <hostAttr>
                <hostName>ns1.example.ir</hostName>
                <hostAddr ip="v4">192.0.2.2</hostAddr>
            </hostAttr>
        </ns>
        <contact type="holder">ex61-irnic</contact>
        <contact type="admin">ex61-irnic</contact>
        <contact type="tech">ex61-irnic</contact>
        <contact type="bill">ex61-irnic</contact>
    </create>
    <auth>
        <code>TOKEN</code>
    </auth>
</mashhadhost>
 
     
     
     
     
    