0

このオブジェクトが返されました:

Array 
( 
[0] => SimpleXMLElement Object 
( 
    [@attributes] => Array 
    ( 
        [Desc] => Amount should be numeric. 
    ) 
) 
[1] => SimpleXMLElement Object 
( 
    [@attributes] => Array 
    ( 
        [Desc] => Please enter your Reference Number. 
    ) 
) 
)

desc 値を取得するにはどうすればよいですか? 両方の Desc Values を取得する必要があります (「金額は数値である必要があります。」と「参照番号を入力してください。」)

私が試してみました:

$res = $str[0];

返されました:

SimpleXMLElement Object 
( 
    [@attributes] => Array 
    ( 
        [Desc] => Amount should be numeric. 
    ) 
 ) 
4

2 に答える 2

2

オブジェクトは SimpleXML オブジェクトです。

ここで使用方法を学ぶことができます:

http://php.net/manual/fr/book.simplexml.php

問題を解決するには、これを使用できます。

$res0 = $str[0]->attributes()->Desc;
$res1 = $str[1]->attributes()->Desc;
于 2013-09-25T09:07:28.930 に答える
1

それらを呼び出しattributes()て、プロパティとしてアクセスします。

$node->attributes()->Desc
于 2013-09-25T09:05:47.010 に答える