0

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 $this->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.

3
  • The content is lost because you change the outertext which (probably) includes the dom-objects contents as well. Commented Feb 6, 2011 at 9:18
  • The doc on your lib is here: simplehtmldom.sourceforge.net/manual.htm#section_access I’m not sure it can add attributes with namespace; in fact, I don’t think so. Attributes are accessed as object attributes thus limited to attribute names, and PHP does not allow : in there AFAIK. Did you consider not using the lib (for this)? Would that be an option? Commented Feb 6, 2011 at 9:22
  • I consider to not to use this lib..any suggestion how to do this? @Kissaki Commented Feb 6, 2011 at 10:17

1 Answer 1

1

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>';
Sign up to request clarification or add additional context in comments.

1 Comment

The result is not successful, it displays only.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.