denza
denza

Reputation: 1298

Cannot get the value of the xml fields

Hi i have this xml response that i parse and i can access the third text field, i have parsed it and i even do a var_dump($xmlObj->TerminalCommandResponse->Text); in which i get on screen

object(SimpleXMLElement)#48 (14) { 
    [0]=> string(4) "BB" 
    [1]=> string(45) " *** BEST QUOTATION ***" 
    [2]=> string(52) "  FOR THIS ITI" 
    [3]=> string(48) " *** BF SEGMENTS 1P/2P ***" 
    ... 
} 

But when i try to directly access:

$XMlText=$xmlObjFourth->TerminalCommandResponse->Text;
var_dump($XMLText[2]); 

It doesn't show anything. I even tried a foreach loop in case i get the keys wrong but still the same issue

<terminal:TerminalRsp xmlns:terminal="terminal_v50_0"  TransactionId="F09006B80A0759BF61F85144F306F735" ResponseTime="527">
    <terminal:TerminalCommandResponse>
        <terminal:Text>BB</terminal:Text>
        <terminal:Text>*** BEST  QUOTATION ***</terminal:Text>
        <terminal:Text>FOR THIS ITI</terminal:Text>
        <terminal:Text>*** BF SEGMENTS 1P/2P ***</terminal:Text>
        <terminal:Text>   PSGR     PSG DES   </terminal:Text>
        <terminal:Text>FQG 1         PY2PC  3640    6201        ADT       </terminal:Text>
        <terminal:Text>    GUARANTEED A                            </terminal:Text>
        <terminal:Text>)>&lt;</terminal:Text>
    </terminal:TerminalCommandResponse>
</terminal:TerminalRsp>

Upvotes: 1

Views: 31

Answers (1)

Deron
Deron

Reputation: 352

Probably it is a special character or a whitespace that is blocking you, it is an interesting issue here what i think will help for starters

  foreach($XMLText as $k=>$tmp)
    {
        var_dump(preg_replace("/[^a-zA-Z0-9\s+]+/", "", $tmp));

    }

this way you can see whats in every field in the XMLText array

Upvotes: 1

Related Questions