0

rest コマンドを使用して特定の情報を取得できます。(ブラウザーに) 表示されるデータは既に XML です。情報を取得した後、サーバー上の XML ファイルに保存するにはどうすればよいですか。

$dom-save コマンドで既に試しましたが、何か間違っているようです。どんな助けでも大歓迎です。コードについては以下を参照してください ($response を XML に保存したいです。)

<?php

require_once 'includes/rest_connector.php';
require_once 'includes/session.php';

// check to see if we start a new session or maintain the current one
checksession();

$rest = new RESTConnector();

$url = "/api/tax_codes/0/";
$rest->createRequest($url,"GET", null, $_SESSION['cookies'][0]);
$rest->sendRequest();

$response = $rest->getResponse();
$error = $rest->getException();

// save our session cookies
if ($_SESSION['cookies']==null) 
$_SESSION['cookies'] = $rest->getCookies();

// display any error message
if ($error!=null)
echo $error;

// display the response
if ($response!=null)
echo $response;
else
echo "There was no response.";  


?>
4

2 に答える 2

1

RESTConneconnector は特定のクラス Lightspeed です。これを使用して解決しました:

ibxml_use_internal_errors(true);//load if improperly formatted
file_put_contents("exportProduct.xml", $responseProduct);

だから、最終的にはとても簡単でした:)

于 2013-01-25T15:45:27.313 に答える
0

RESTConnector クラスについては何も知りません。しかし、次のようなことを試すことができると思います。

$dom = new DOMDocument('1.0','utf-8');
$dom->preserveWhiteSpace = false;
$dom->formatOutput = true;
$dom->loadXML($response->asXML());
$dom->save($this->fileexport);
于 2013-01-25T09:38:08.407 に答える