我有一个xml有一个href链接的问题,我不能以正确的顺序回显。PHP的 - 如何解析从HTML与HTML标签的链接?
XML:
290
204
420
70
SOME TEXT
[email protected]
SOME TEXT
我moduletext功能:
class modules
{
private $xml;
protected $build;
// div text
public $div_x, $div_y, $div_width, $div_height, $title, $post, $date, $caption_fontfamily, $caption, $caption_fontsize, $caption_color, $caption_ls, $serverEmail, $name, $email, $message, $src;
private $direction, $fontFamily, $af_color, $color, $bold, $italic, $underline, $af_bold, $af_italic, $af_underline, $size;
// P
public $p_attr_color, $p_attr_align, $p_attr_fontfamily, $p_attr_fontsize, $p_content, $p_content_temp;
// Image module
private $img_path, $img_x, $img_y, $img_rotation, $img_width, $img_height;
// Shape module
private $shape_x, $shape_y, $shape_width, $shape_height, $fill_color, $border_color, $border_size, $shape_type, $alpha, $rotation, $prettyPrinting, $opacity;
public function moduleText($xml,$print = '')
{
$this->xml = new SimpleXMLElement($xml);
// Plocka ut XML-data
$this->div_x = $this->xml->x;
$this->div_y = $this->xml->y;
$this->div_width = $this->xml->width;
$this->div_height = $this->xml->height;
$this->divStart = $this->xml->htmlText[0]->TEXTFORMAT->attributes->LEADING;
$this->build = '
foreach($this->xml->htmlText as $htmltext)
{
foreach($htmltext as $textformat)
{
$line_height = $textformat->attributes()->LEADING;
foreach($textformat as $p)
{
foreach($p as $font)
{
if(isset($font->A))
{
foreach($font->A as $link) {
$size = $link->attributes()->SIZE;
$target .= $link->attributes()->TARGET;
$this->build .= '
';}
}
$fontsize = $font->attributes()->SIZE;
$fontfamily = str_ireplace(array('_'), array(''), $font->attributes()->FACE);
$fontcolor = $font->attributes()->COLOR;
$test = "1.305";
if(strlen($font) > 0) {
$this->build .= '
if(isset($font->A)) {
$this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('','','',''), $font . '
} else {
$this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('','','',''), $font . '
}
}
if(strlen($font->I) > 0) {
$this->build .= '
$this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('','','',''), "".$font->I . '
}
if(strlen($font->U) > 0) {
$this->build .= '
$this->build .= iconv('UTF-8','ISO-8859-1', str_ireplace(array('[b]','[/b]','[i]','[/i]'), array('','','',''), "".$font->U . ''));
$this->build .= '
}
if(strlen($font) == 0 && strlen($font->U) == 0 && strlen($font->I) == 0) {
$this->build .= '
}
}
}
}
}
$this->build .= '