Hello!

Basically, I am working on a script that is supposed to convert table data from metric to imperial data. I want to pare XHTML pages (containing up to three different tables) with the PHP DOM functions in order to be able to access and manipulate the tables one by one. Parsing and retrieving table headers and cells is not the problem. The problem right now is how to replace data in the headers.

Here is a rather simplified  example of a table I want to convert:

Header contains: Product | Lenght <br /> mm | Width <br />mm | Weight <br /> kg

As you can see, table headers can contain one or more words and a (optional) line break. Currently, I am able to get all headers as a list of nodes from where I can access all headers one by one. But when I try to replace some content like this:

# $nodeElement contains the current text node from a header

$str = "some new content";
$new_header_element = $doc -> createTextNode ( $str );
$nodeElement -> parentNode -> replaceChild ( $new_element, $nodeElement );

.. I am able to replace e.g. "Product", "Length" or "Width". I am not able to access / replace anything after the line-break. Why? I have already tested to get to this content with $nodeElement -> childNodes; but this will throw an error.

Hopefully, I was able to explain my problem to you... OOP and especially working with the DOM functions are still very new to me, so please be patient with me.

If anyone has an idea, I would love to hear about it. Otherwise, there might be someone how can point me to some good on-line documentation / tutorials regarding PHP DOM functions.

Thank you and good night.
/frank

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to