开发者

Insert attribute in a <html> line

I wan to insert this line of code:

xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>"

to this line of code:

<html xmlns="http://www.w3.org/1999/xhtml">

so the output is like this:

<html xmlns="http://www.w3.org/1999/xhtml" 
xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>" >

I'm using this: Simple DOM Parser

when use this:

$html->find('html', 0)->outertext = '<html xmlns="http://www.w3.org/1999/xhtml" 
xml:lang="<?php echo $t开发者_开发技巧his->language; ?>" lang="<?php echo $this->language; ?>" > ';

The whole HTML file will be lost and will be replaced by the code above. It's getting all the outertext of HTML. But I just want to change the line of HTML code.


You can do this, using Simple DOM Parser:

$content = $html->find('html', 0);
$content->outertext = '<html xmlns="http://www.w3.org/1999/xhtml" 
xml:lang="<?php echo $this->language; ?>" lang="<?php echo $this->language; ?>">'.$content->innertext().'</html>';
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜