XML : Getting Status of xml

I am working with the amazon API and I need to check the status of the XML. For example:

  <GetMatchingProductForIdResult status="Success" IdType="UPC" Id="082686068055">    

or

  <GetMatchingProductForIdResult status="ClientError" IdType="UPC" Id="082686068055">    

How would I go about writing a code that checks if the status is not "Success"? The XML looks like this:

  <GetMatchingProductForIdResponse xmlns="http://mws.amazonservices.com/schema/Products/2011-10-01">    <GetMatchingProductForIdResult status="Success" IdType="UPC" Id="082686068055">      <Products>        <Product>          <Identifiers>            ...           </Identifiers>          <AttributeSets>          </AttributeSets>        </Product>      </Products>    </GetMatchingProductForIdResult>    

The first tag stays throughout the whole XML file. The tag closes at the end of the file. I am using SimpleXML to open, and get all of the other data needed from the file, but I always have an error when the tags in <AttributeSets> is not valid. I need to find a way to avoid this problem. Thanks in advance.

No comments:

Post a Comment