0

通信しているサイトがメンテナンスのためにダウンしているときに、次の XML メッセージを受信して​​います。「通常のシステム メンテナンスを実行している間、xxxxxxxxx.com は一時的に利用できません」というエラー メッセージを検出して取得する必要があります。誰かが助けてくれることを願っています!

SimpleXMLElement Object (
  [head] => SimpleXMLElement Object ( 
    [meta] => SimpleXMLElement Object (
      [@attributes] => Array ( 
        [http-equiv] => Content-Type 
        [content] => text/html; charset=UTF-8 
      ) 
    ) 
    [title] => Updates In Progress 
    [link] => SimpleXMLElement Object ( 
      [@attributes] => Array ( 
        [href] => style/style.css 
        [rel] => stylesheet 
        [type] => text/css 
      ) 
    ) 
  ) 
  [body] => SimpleXMLElement Object (
    [div] => SimpleXMLElement Object (
      [@attributes] => Array (
        [id] => container 
      ) 
      [div] => Array (
        [0] => SimpleXMLElement Object ( 
          [@attributes] => Array ( 
            [id] => header 
          ) 
          [img] => SimpleXMLElement Object ( 
            [@attributes] => Array ( 
              [src] => images/top_banner.jpg 
              [alt] => xxx Freight | Updates In Progress 
            ) 
          ) 
        ) 
        [1] => SimpleXMLElement Object ( 
          [@attributes] => Array ( 
            [id] => wrapper 
          ) 
          [div] => Array ( 
            [0] => SimpleXMLElement Object ( 
              [@attributes] => Array ( 
                [id] => leftCol 
              ) 
              [p] => Array ( 
                [0] => SimpleXMLElement Object ( 
                  [strong] => SYSTEM MAINTENANCE 
                ) 
                [1] => xxxxxx.com is temporarily unavailable while we perform regular system maintenance. 
                [2] => We're sorry for the inconvenience. Please check back soon. 
              ) 
            ) 
            [1] => SimpleXMLElement Object ( 
              [@attributes] => Array ( 
                [id] => rightCol 
              ) 
              [p] => For immediate assistance, please contact Customer Service at 1-800-610-6500. 
            ) 
            [2] => SimpleXMLElement Object ( 
              [@attributes] => Array ( 
                [class] => clearfloat 
              ) 
            ) 
          ) 
        ) 
      ) 
    ) 
  ) 
) 
4

1 に答える 1

0

simpexml_tree()を使用して SimpleXML オブジェクトを出力してみてください。それが与える出力は、必要なノードを見つけるために必要な操作を示唆しているはずです。

ただし、SimpleXML は、入力が有効な XML であり、これが HTML である場合にのみ機能することに注意してください。有効な XML であるとは限りません。

可能であれば、サーバーから返される HTTP ステータスをチェックし (CURLCURLOPT_HEADERFUNCTIONオプションを使用するなど)、サーバーがダウンしたときに標準の 5xx ステータスを返すかどうかを確認します。(通常は 500 または 503)。

于 2012-10-22T14:54:40.273 に答える