GoLang DOMDocument::getElementsByTagName

request it (100)
GoLang replacement for PHP's DOMDocument::getElementsByTagName [edit | history]

Do you know a GoLang replacement for PHP's DOMDocument::getElementsByTagName? Write it!

PHP DOMDocument::getElementsByTagName

PHP original manual for DOMDocument::getElementsByTagName [ show | php.net ]


(PHP 5, PHP 7)

DOMDocument::getElementsByTagNameSearches for all elements with given local tag name


public DOMNodeList DOMDocument::getElementsByTagName ( string $name )

This function returns a new instance of class DOMNodeList containing all the elements with a given local tag name.



The local name (without namespace) of the tag to match on. The special value * matches all tags.

Return Values

A new DOMNodeList object containing all the matched elements.


Example #1 Basic Usage Example

= <<< XML
<?xml version="1.0" encoding="utf-8"?>
 <book>Patterns of Enterprise Application Architecture</book>
 <book>Design Patterns: Elements of Reusable Software Design</book>
 <book>Clean Code</book>

$dom = new DOMDocument;
$books $dom->getElementsByTagName('book');
foreach (
$books as $book) {

The above example will output:

Patterns of Enterprise Application Architecture
Design Patterns: Elements of Reusable Software Design
Clean Code

See Also