我想从我的XML参数文件中获取href
;这是我的代码:
$linkx = $params->get('linkx');
echo '<a href="$linkx"><p class="bottomp"> Find More </a>';
这样做的正确方法是什么?
答案 0 :(得分:1)
<?php
$doc = new SimpleXMLELement( data() );
$fields = $doc->xpath('//form[@id="form2"]/field');
foreach( $fields as $f) {
printf('name=%s, type=%s, label=%s%s', $f['name'], $f['type'], $f['label'], PHP_EOL);
}
function data() {
return <<< eot
<data>
<form id="form1"></form>
<form id="form2">
<field name="linkx" type="text" label="Find More Link" description="Link to more news" />
<field name="linky" type="text" label="..." description="---" />
</form>
<form id="form3"></form>
</data>
eot;
}
打印
name=linkx, type=text, label=Find More Link
name=linky, type=text, label=...