Frank Arensmeier wrote: > 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 not all of it - because the 'current' text is actual a series of text and xml nodes (each <br /> and the text between being a seperate node) > > $str = "some new content"; > $new_header_element = $doc -> createTextNode ( $str ); > $nodeElement -> parentNode -> replaceChild ( $new_element, $nodeElement ); you'll need to remove all children of parentNode and then append the new node (for arguments sake - you could do it another way but the result would/should be the same) because the contents of the 'Header' (the parentNode) is actually a set of nodes: i.e. this: Product | Lenght <br /> mm | Width <br />mm | Weight ammounts to this (pseudo markup): <textNode/><xmlNode/><textNode/><xmlNode/><textNode/> and you are currently replacing only the first [text]node hth > > .. 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 > -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php