8000 Return html from node + removing forcing charset by radupb · Pull Request #8 · symfony/dom-crawler · GitHub
[go: up one dir, main page]

Skip to content

Return html from node + removing forcing charset #8

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Added function to return the html of a node
html()
  • Loading branch information
radupb committed Nov 2, 2012
commit 251f1819c097c104b2e359d7d3eb68d779c12f14
23 changes: 23 additions & 0 deletions Crawler.php
Original file line number Diff line number Diff line change
Expand Up @@ -468,6 +468,29 @@ public function text()

return $this->getNode(0)->nodeValue;
}

/**
* Returns the html of a node
* @return string The node html
*
* @throws \InvalidArgumentException When current node is empty
*
* @api
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@api should be removed.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll admit, I have simply copied the comment from the text() function above.

*/
public function html() {

if (!count($this)) {
throw new \InvalidArgumentException('The current node list is empty.');
}

foreach ($this->getNode(0)->childNodes as $child) {
$html .= $child->ownerDocument->saveXML($child);
}


return str_replace('
', '', $html);
}


/**
* Extracts information from the list of nodes.
Expand Down
0