---
title: "Extending extension where I needs to use DOM"
url: "https://www.typo3.net/d/108102-extending-extension-where-i-needs-to-use-dom"
source: "typo3.net"
tags: ["Extensions","PHP","English","Frage"]
created: "2011-11-07"
last_reply: "2011-11-07"
replies: 0
solved: false
page: 1
pages: 1
lang: "en"
---

# Extending extension where I needs to use DOM

Extensions › PHP · 0 Antworten · gestartet 2011-11-07

## Eröffnungsbeitrag

**xescjp** · 2011-11-07 · [Beitrag #1](https://www.typo3.net/d/108102-extending-extension-where-i-needs-to-use-dom/1)

I am creating an extended extension and I need to parse the HTML. I need to use DOM inside the extension.
I have copied php_domxml.dll to ext directory of php extensions.
I have write extension=php_domxml.dll in php.ini.
I use the following code but doesn't work. The first line doesn't work because I have checked the value of $doc variable and its null.

$doc = new DOMDocument();

$doc->loadHTML($contingut);
		/*** a new dom object ***/
		$doc = new domDocument;

/*** discard white space ***/
    		$doc->preserveWhiteSpace = false;

/*** the table by its tag name ***/
    		$table = $doc->getElementById('directori');

/*** get all rows from the table ***/
    		$rows = $table->getElementsByTagName('tr');

/*** loop over the table rows ***/
    		foreach ($rows as $row)
    		{
        		/*** get each column by tag name ***/
        		$cols = $row->getElementsByTagName('td');
        		/*** echo the values ***/
        		$contingut.= $cols->item(0)->nodeValue.'<br />';
        		$contingut.=$cols->item(1)->nodeValue.'<br />';
        		$contingut.=$cols->item(2)->nodeValue;
        		$contingut.='<hr />';
    		}

Anybody could tell me how to use dom in a typo3 extension?

Thanks in advance

Francesc

---

Quelle: „Extending extension where I needs to use DOM“, typo3.net, https://www.typo3.net/d/108102-extending-extension-where-i-needs-to-use-dom
Beiträge von Mitgliedern des Forums. Bitte mit Link auf die Diskussion zitieren.
