找不到PHP类,从头开始创建XML文档

时间:2012-08-19 21:20:35

标签: php xml

我正在尝试从php.net(下面的代码)中完成一个示例,它允许您创建SDO数据图并将其保存为XML字符串。

<?php
/**
 * Create an XML document from scratch
 */
try {
   $xmldas = SDO_DAS_XML::create("letter.xsd");
   try {
       $doc = $xmldas->createDocument();
       $rdo = $doc->getRootDataObject();
       $seq = $rdo->getSequence();
       $seq->insert("April 09, 2005", NULL, 'date');
       $seq->insert("Acme Inc. ", NULL, NULL);
       $seq->insert("United Kingdom. ");
       $seq->insert("Dear", NULL, NULL);
       $seq->insert("Tarun", NULL, "firstName");
       $seq->insert("Nayaraaa", NULL, "lastName");
       $rdo->lastName = "Nayar";
       $seq->insert("Please note that your order number ");
       $seq->insert(12345);
       $seq->insert(" has been dispatched today. Thanks for your business with us.");
       print($xmldas->saveString($doc));
   } catch (SDO_Exception $e) {
       print($e);
   }
} catch (SDO_Exception $e) {
   print("Problem creating an XML document: " . $e->getMessage());
}
?>

当我尝试运行代码时,我收到以下错误:

Fatal error: Class 'SDO_DAS_XML' not found in C:\xampp\htdocs\test.php on line 6

1 个答案:

答案 0 :(得分:0)

您需要先安装SDO包。

请参阅SDO Installation Docs了解详情

编辑:对于Windows,你需要为你的php版本找到一个sdo.dll,如果有人已经编译了一个或自己构建它。

请参阅Installing a PHP extension on Windows