当前位置: 首页>>代码示例>>PHP>>正文


PHP XmlManager::query方法代码示例

本文整理汇总了PHP中XmlManager::query方法的典型用法代码示例。如果您正苦于以下问题:PHP XmlManager::query方法的具体用法?PHP XmlManager::query怎么用?PHP XmlManager::query使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在XmlManager的用法示例。


在下文中一共展示了XmlManager::query方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: XmlManager

book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
#
# This is a very simple example of using try/catch and XmlException
# to get information on an exception thrown from Berkeley DB XML.
# The line that generates the exception is the query, which uses
# bad XQuery syntax.
#
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
$mgr = new XmlManager();
try {
    $con = $mgr->createContainer("test.dbxml");
    $con->putDocument($book_name, $book_content);
    $qc = $mgr->createQueryContext();
    $res = $mgr->query("collection('test.dbxml')/x[", $qc);
    $doc = $con->getDocument("foo");
    $s = $doc->getContentAsString();
    print $doc->getName() . " = {$s}\n";
    unset($doc);
    unset($con);
} catch (XmlException $xe) {
    print "XmlException message: " . $xe->what() . "\n";
    print "XmlException code: " . $xe->getExceptionCode() . "\n";
    print "XmlException dbErrno: " . $xe->getDbErrno() . "\n";
    print "Query line: " . $xe->getQueryLine() . "\n";
    print "Query column: " . $xe->getQueryColumn() . "\n";
    unset($con);
}
$mgr->removeContainer("test.dbxml");
开发者ID:kanbang,项目名称:Colt,代码行数:31,代码来源:exceptionExample.php

示例2: resolveDocument

Currently non-functional.
<?php 
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
class myResolver extends XmlResolver
{
    function resolveDocument($uri, &$result)
    {
        print "In resolveDocument({$uri})\n";
        $result = new XmlValue("<a><b>b</b></a>");
        return true;
    }
    function resolveCollection($uri, &$result)
    {
        print "In resolveCollection({$uri})\n";
        return false;
    }
}
$r = new myResolver();
$mgr = new XmlManager();
$mgr->registerResolver($r);
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$results = $mgr->query("doc('myscheme:xxx')/root");
print_r($results);
开发者ID:kanbang,项目名称:Colt,代码行数:25,代码来源:12.php

示例3: XmlManager

Create an XmlContainer, add a document that includes a
namespace definition, create a query context, define a
namespace prefix to URI mapping, query the container
for the document within a context, iterate over the
result set displaying the values returned.

EXPECTED RESULT:
book1_ns = <book xmlns:books="http://foo.bar.com/books.dtd"><books:title>Knowledge Discovery in Databases.</books:title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1_ns';
$book_content = "<book xmlns:books='http://foo.bar.com/books.dtd'><books:title>Knowledge Discovery in Databases.</books:title></book>";
$container_name = 'test.dbxml';
$mgr = new XmlManager(null);
if (file_exists("test.dbxml")) {
    $mgr->removeContainer("test.dbxml");
}
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$qc = $mgr->createQueryContext();
$qc->setNamespace("books2", "http://foo.bar.com/books.dtd");
$results = $mgr->query("collection('test.dbxml')/*[books2:title='Knowledge Discovery in Databases.']", $qc);
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}
开发者ID:kanbang,项目名称:Colt,代码行数:28,代码来源:03.php

示例4: XmlManager

Create an XmlManager/XmlContainer, add a document, query the container
for the document, iterate over the result set displaying the
values returned.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = '<book><title>Knowledge Discovery in Databases.</title></book>';
$container_name = 'test.dbxml';
$mgr = new XmlManager();
if (file_exists("test.dbxml")) {
    $mgr->removeContainer("test.dbxml");
}
$con = $mgr->createContainer("test.dbxml");
$con->putDocument($book_name, $book_content);
$results = $mgr->query("collection('test.dbxml')/book");
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}
开发者ID:kanbang,项目名称:Colt,代码行数:24,代码来源:02.php

示例5: XmlManager

Create an XmlContainer, define an equality string index
for booktitle elements, add a document, create a query
context, define a variable binding, query the container
for the document within a context referencing the variable
defined, iterate over the result set displaying the values
returned.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = "<book><title>Knowledge Discovery in Databases.</title></book>";
$container_name = 'test.dbxml';
unlink($container_name);
$mgr = new XmlManager(null);
$con = $mgr->createContainer("test.dbxml");
$con->addIndex("", "title", "node-element-equality-string");
$con->putDocument($book_name, $book_content);
$qc = $mgr->createQueryContext();
$qc->setVariableValue("title", "Knowledge Discovery in Databases.");
$results = $mgr->query("collection('test.dbxml')//*[title=\$title]", $qc);
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}
开发者ID:kanbang,项目名称:Colt,代码行数:28,代码来源:05.php

示例6: XmlManager

Create an XmlContainer, define an equality string index
for booktitle elements, add a document, query the container
for the document, iterate over the result set displaying
the values returned.

EXPECTED RESULT:
book1 = <book><title>Knowledge Discovery in Databases.</title></book>
ACTUAL RESULT:
<?php 
$book_name = 'book1';
$book_content = "<book><title>Knowledge Discovery in Databases.</title></book>";
$container_name = 'test.dbxml';
unlink($container_name);
$mgr = new XmlManager(null);
$con = $mgr->createContainer("test.dbxml");
$con->addIndex("", "title", "node-element-equality-string");
$con->putDocument($book_name, $book_content);
$results = $mgr->query("collection('test.dbxml')//*[title='Knowledge Discovery in Databases.']");
$results->reset();
while ($results->hasNext()) {
    $val = $results->next();
    $doc = $val->asDocument();
    print $doc->getName() . " = " . $val->asString() . "\n";
}
开发者ID:kanbang,项目名称:Colt,代码行数:24,代码来源:04.php


注:本文中的XmlManager::query方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。