Jump to content
Sign in to follow this  
hungryfrank

problem with parsing xml

Recommended Posts

i am having a problem parsing the file that ebay returns for error codes


  $results = new SimpleXMLElement($responseXml);
 if ( $results->Errors != null )

		foreach ($results->Errors as $key => $value) {
            
                $longMsg =$results->Errors->LongMessage;
		$shortMsg = $results->Errors->ShortMessage;
		$code = $results->Errors->ErrorCode;
		echo '<P>' . $code . ' : ' . str_replace( ">", ">", str_replace( "<", "<", $shortMsg ) );
			if ( $longMsg != '' )
				echo '<BR>' . str_replace( ">", ">", str_replace( "<", "<", $longMsg ) );

								}
				
	echo "<br>";
}

but i get the same entery repeated again. 

here is  XML file

SimpleXMLElement Object
(
    [Timestamp] => 2017-08-03T19:38:29.478Z
    [Ack] => Warning
    [Errors] => Array
        (
            [0] => SimpleXMLElement Object
                (
                    [ShortMessage] => Unrecognized element <ActiveList.EntriesPerPage> in request message.
                    [LongMessage] => The element <ActiveList.EntriesPerPage> was found in the input request message.  This is not a declared element in the schema and will be ignored.
                    [ErrorCode] => 21927
                    [SeverityCode] => Warning
                    [ErrorParameters] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [ParamID] => 0
                                )

                            [Value] => ActiveList.EntriesPerPage
                        )

                    [ErrorClassification] => RequestError
                )

            [1] => SimpleXMLElement Object
                (
                    [ShortMessage] => Unrecognized element <ActiveList.PageNumber> in request message.
                    [LongMessage] => The element <ActiveList.PageNumber> was found in the input request message.  This is not a declared element in the schema and will be ignored.
                    [ErrorCode] => 21927
                    [SeverityCode] => Warning
                    [ErrorParameters] => SimpleXMLElement Object
                        (
                            [@attributes] => Array
                                (
                                    [ParamID] => 0
                                )

                            [Value] => ActiveList.PageNumber
                        )

                    [ErrorClassification] => RequestError
                )

        )

Share this post


Link to post
Share on other sites

Do you see any references to $key or $value in your loop? Me neither. Then how do you expect to get the entries?

 

If you don't remember how loops work, relearn the PHP basics before you start any complex project.

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Sign in to follow this  

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.