本文整理汇总了PHP中XMLParser::parseByData方法的典型用法代码示例。如果您正苦于以下问题:PHP XMLParser::parseByData方法的具体用法?PHP XMLParser::parseByData怎么用?PHP XMLParser::parseByData使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类XMLParser
的用法示例。
在下文中一共展示了XMLParser::parseByData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getFAQ
public static function getFAQ()
{
if (!($data = @file_get_contents(self::getFilename()))) {
throw new ErrorException(self::ERROR_READING_FILE);
}
/**
* Let's replace some of the docbook tags and wrap some HTML-entities
* inside CDATA containers.
*/
$pattern = array('/<ulink\\s+url="(.+)">(.+)<\\/ulink>/isU', '/<itemizedlist>(.+)<\\/itemizedlist>/isU', '/<listitem><simpara>(.+)<\\/simpara><\\/listitem>/isU', '/<simpara>(.+)<\\/simpara>/isU', '/<emphasis>(.+)<\\/emphasis>/isU', '/<envar>(.+)<\\/envar>/isU', '/<command(?:\\s+[^>]+)?>(.+)<\\/command>/isU', '/<blockquote>(.+)<\\/blockquote>/isU', '/<programlisting(?:\\s+[^>]+)?>(.+)<\\/programlisting>/isU', '/<quote>(.+)<\\/quote>/isU', '/<xref linkend="(.+)"\\s+endterm=".+"\\/>/isU', '/(&(?:lt|gt|quot);)/is');
$replace = array('<h:a href="\\1">\\2</h:a>', '<h:ul>\\1</h:ul>', '<h:li>\\1</h:li>', '<h:p>\\1</h:p>', '<h:span class="italic">\\1</h:span>', '<h:span class="envar">\\1</h:span>', '<h:span class="bold">\\1</h:span>', '<h:blockquote>\\1</h:blockquote>', '<h:pre>\\1</h:pre>', '“<h:span class="quote">\\1</h:span>”', '<h:a xref="\\1"/>', '<![CDATA[\\1]]>');
$data = preg_replace($pattern, $replace, $data);
/* Remove this weird character as it displays as À in Firefox. */
$data = str_replace(chr(194), '', $data);
/* Now parse the data. */
$parser = new XMLParser();
$a = $parser->parseByData($data);
$sections = array();
/**
* Build a map of the defined hrefs so we can give the xrefs the correct
* text.
*/
$xref = array();
$count = 1;
foreach ($a['faq']['section'] as $data) {
$sections[] = new QASection($data, $count++, $xref);
}
return $sections;
}