链接到同一文档中的另一个XML节点

时间:2017-01-30 07:46:41

标签: xml xml-parsing pugixml

XML文件:

<Test name="B6">

我想将<?php $username = 'mongodbusername'; $password = 'changeMe'; $m = new MongoClient("mongodb://myadmin1:myadmin123@localhost/dbname"); //$m = new MongoClient("mongodb://localhost", array("username" => $username, "password" => $password,"db" => "jobma_integrations")); $db = $m->integrations; // this is your dbname $crawlingCollection = $db->crawled_jobs; // this is your collection name $c = $crawlingCollection->find( ['$text' => ['$search' => "sales \"ardmore\""]], // this \"ardmore\" is used for exact match and sales will be match with any where ['score'=> ['$meta'=>'textScore']] )->sort( ['score'=> ['$meta'=>'textScore']] ); echo "<pre>"; var_dump(iterator_to_array($c)); ?> 的内容与{{1}}相关联,以避免重新输入相同的数据! (需要不同的名称)需要哪个语句来引用此XML节点? (pugixml应该能够正确解析它)

1 个答案:

答案 0 :(得分:1)

XML不支持此类引用。您可以使用自定义&#34;语法&#34;来解决此问题。和自定义C ++代码,例如:

public class SendMailException : Exception {
    public SendMailException(Exception cause) : base(cause) {
    }
}
...
try {
    SmtpServer.Send(mail);
    // return true is removed
} catch (Exception cause) {
    throw new SendMailException(cause);
    // return false is removed
}

可以加载如下代码:

<?xml version="1.0"?>
<Common>
    <Test name="B1">
        <Test id="100"><Name>a test</Name></Test>
        <Test id="101"><Name>another test</Name></Test>
    </Test>
    <Test name="B2">
        <Test id="500"><Name>a simple test</Name></Test>
        <Test id="501"><Name>another simple test</Name></Test>
    </Test>
    <Test name="B6">
        <?link /Common/Test[@name='B2']?>
    </Test>
</Common>