Copying HTML from a document to another document

php.internals

Sam Hobbs

21 years ago
Please see: Copying HTML from a document to another document http://marc.theaimsgroup.com/?l=php-general&m=109419037409980&w=2 It has been more than two weeks without a reply. I suspect there is a bug in PHP. I assume the people looking at that list can't answer the question. Am I supposed to ask questions such as that in this list instead.?

Christian Stocker

21 years ago
On 19.9.2004 20:30 Uhr, Sam Hobbs wrote:
> Please see: > > Copying HTML from a document to another document > http://marc.theaimsgroup.com/?l=php-general&m=109419037409980&w=2 > > It has been more than two weeks without a reply. I suspect there is a bug in > PHP. I assume the people looking at that list can't answer the question. > > Am I supposed to ask questions such as that in this list instead.?
Nope, file a bug report, if you think, it's a bug ;) But don't bother, it's not a bug. You have to use $DomDocuemnt->importNode(), if you want to copy a node from one document to another. See http://ch.php.net/manual/en/function.dom-domdocument-importnode.php and the W3C docs. chregu
>
-- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | chregu@bitflux.ch | gnupg-keyid 0x5CE1DECB

Sam Hobbs

21 years ago
"Christian Stocker" <chregu@bitflux.ch> wrote in message news:414DD1DD.80205@bitflux.ch...
> > > On 19.9.2004 20:30 Uhr, Sam Hobbs wrote: >> Please see: >> >> Copying HTML from a document to another document >> http://marc.theaimsgroup.com/?l=php-general&m=109419037409980&w=2 >> >> It has been more than two weeks without a reply. I suspect there is a bug >> in PHP. I assume the people looking at that list can't answer the >> question. >> >> Am I supposed to ask questions such as that in this list instead.? > > Nope, file a bug report, if you think, it's a bug ;) > > But don't bother, it's not a bug. You have to use > $DomDocuemnt->importNode(), if you want to copy a node from one document > to another. See > http://ch.php.net/manual/en/function.dom-domdocument-importnode.php > and the W3C docs.
I did try many things, including importNode. I did look at the documentation as much as I can. I looked at many other sites. I converted the PHP code to JavaScript, as I said in the other message. The JavaScript version does not need importNode. I have heard the "read the manual" song many times. Just saying look at the manual does not help. How do I use importNode to do this? The manual does not explain how and does not help me to understand how. People seem so quick to criticize and slow to help.

dharana

21 years ago
http://www.catb.org/~esr/faqs/smart-questions.html Sam Hobbs wrote:
> "Christian Stocker" <chregu@bitflux.ch> wrote in message > news:414DD1DD.80205@bitflux.ch... > > > I did try many things, including importNode. I did look at the documentation > as much as I can. I looked at many other sites. I converted the PHP code to > JavaScript, as I said in the other message. The JavaScript version does not > need importNode. > > I have heard the "read the manual" song many times. Just saying look at the > manual does not help. How do I use importNode to do this? The manual does > not explain how and does not help me to understand how. > > People seem so quick to criticize and slow to help. >
-- Juan Alonso http://gamersmafia.com | http://laflecha.net

Sam Hobbs

21 years ago
I am sorry for getting impatient, but I truly believe that my original question was very reasonalble and relevant. If not, then it would help for someone to be clear about the problem. The very vague answers don't help me; I sure don't understand what the problem is. If the "How To Ask Questions The Smart Way" article is supposed to apply to the question in the other group, then I assume that the moderators would prefer that the replies to it be made in that group. I am sorry for replying in this group if the message I am replying to should have been in that group. So just to attempt to undestand the relevance of the "How To Ask Questions The Smart Way" article, the following will attempt to get clarification. I think that simply posting a reference to the article is far too vague to be helpful. I did try to find an answer by reading the manual. I did try to find an answer by searching the Web. Is there a relevant FAQ that I don't know about? Is that what you are tryig to say? I did try to find an answer by inspection and experimentation. I don't know a skilled friend that can help, except I did post in other forums. Are you saying I should read the PHP source code instead of asking in the forums? I sure did try to choose the proper forum, and I asked what forum is proper. There are not relevant Web and IRC forums other than these, correct? I did try a couple of other PHP forums, if that is what you mean. Is there another forum that I am supposed to be using? Note I did ask where I should post the question to. I am using project mailing lists (newsgroups), right? I sure tried to use a meaningful, specific subject header! I tried to make it as easy as possible to reply with a solution. I provided a small self-contained peice of code that duplicated the problem. Did I not write in clear, grammatical, correctly-spelled language? Is that the problem? Is my question in a format that is not easy to understand? I did not want to provide unnecessary and irrelevant information. Is my question imprecise or incomplete? Is my question too much? I did not say in my original question that I have a bug. I did not say that there is a bug; I said there might be a bug. If there is not a bug then why can't anyone provide a solution? Again, if there is not a bug, then what is the solution? Note that the PHP DOM extension is defined to implement the standard, so if it does not, then that could be considered to be a bug. I have seen questions from people that are convinced that something is a bug. In those situations, they don't describe the problem they are having well enough for others to help them solve the problem that is their problem. That is the problem with saying that there is a bug. I hope I did describe my problem in a manner that makes it possible to provide a solution to whatever I am doing wrong. Perhaps I should not have used the "bug" word. Is that why you refuse to help? What other homework should I have done? If there is something more I should have done, then perhaps I just need to know what it is. I tried to describe the problem as best I could. Did I not describe it well? Should I have not stated my guess, such as the possibility of a bug? Again, I think I was very explicit about the question. So again, I am sorry for becoming impatient, but instead of criticizing my impatience, if someone can simply answer the question in the same manner I would if I had the answer, then that is all I am asking for. If roles were reversed, I would sure consider the question to be a good question. "Dharana" <dharana@dharana.net> wrote in message news:414DE174.60508@dharana.net...

Rasmus Lerdorf

21 years ago
Would you please stop asking questions that have nothing to do with low-level PHP internals on the internals list. You are getting gruff responses because your posts are completely off-topic to this list. Post such questions to php-general. If you don't get a response, coming in here and brow-beating us is not going to get you anywhere. -Rasmus

Sam Hobbs

21 years ago
"Rasmus Lerdorf" <rasmus@php.net> wrote in message news:Pine.LNX.4.58.0409191413050.2557@t42p.lerdorf.com...
> Would you please stop asking questions that have nothing to do with > low-level PHP internals on the internals list. You are getting gruff > responses because your posts are completely off-topic to this list. Post > such questions to php-general. If you don't get a response, coming in > here and brow-beating us is not going to get you anywhere. > > -Rasmus
Then all that was necessary to my original question in this group is to say that it probably is not a bug and that the answer should be provided in the other forum. All the other stuff is not necessary. This discussion could have ended as quickly as it began.

Christian Stocker

21 years ago
On 19.9.2004 21:38 Uhr, Sam Hobbs wrote:
> "Christian Stocker" <chregu@bitflux.ch> wrote in message > news:414DD1DD.80205@bitflux.ch... > >> >>On 19.9.2004 20:30 Uhr, Sam Hobbs wrote: >> >>>Please see: >>> >>>Copying HTML from a document to another document >>>http://marc.theaimsgroup.com/?l=php-general&m=109419037409980&w=2 >>> >>>It has been more than two weeks without a reply. I suspect there is a bug >>>in PHP. I assume the people looking at that list can't answer the >>>question. >>> >>>Am I supposed to ask questions such as that in this list instead.? >> >>Nope, file a bug report, if you think, it's a bug ;) >> >>But don't bother, it's not a bug. You have to use >>$DomDocuemnt->importNode(), if you want to copy a node from one document >>to another. See >>http://ch.php.net/manual/en/function.dom-domdocument-importnode.php >>and the W3C docs. > > > I did try many things, including importNode. I did look at the documentation > as much as I can. I looked at many other sites. I converted the PHP code to > JavaScript, as I said in the other message. The JavaScript version does not > need importNode. > > I have heard the "read the manual" song many times. Just saying look at the > manual does not help. How do I use importNode to do this? The manual does > not explain how and does not help me to understand how.
http://www.w3.org/TR/DOM-Level-2-Core/core.html#Core-Document-importNode explains it all quite good. And it's no guarantee, that it works in php5, if it works in JS (the JS implementations aren't flawless ;) )
> People seem so quick to criticize and slow to help.
This is soooo the wrong place for whining again about "nobody's helping me"... Please move along, nothing to see here. chregu
-- christian stocker | Bitflux GmbH | schoeneggstrasse 5 | ch-8004 zurich phone +41 1 240 56 70 | mobile +41 76 561 88 60 | fax +41 1 240 56 71 http://www.bitflux.ch | chregu@bitflux.ch | gnupg-keyid 0x5CE1DECB

Sam Hobbs

21 years ago
"Christian Stocker" <chregu@bitflux.ch> wrote in message news:414DF200.30409@bitflux.ch...
> > http://www.w3.org/TR/DOM-Level-2-Core/core.html#Core-Document-importNode > > explains it all quite good. And it's no guarantee, that it works in php5, > if it works in JS (the JS implementations aren't flawless ;) )
I think it is reasonable to ask for the one or two lines of PHP code that solves the problem. As I have said, I did try to do it myself. I do realize that the JavaScript solution might use a non-standard extension. There is an article someone found (that uses Java, not JavaScript) that does say that importNode is needed, but I don't know how to convert that sample code to PHP also. We could discuss that too, but I am still not sure if this (the internals) newsgroup/forum is where that should be done. So again, if these replies should be in the other forum, then I am sorry for replying in this forum. If someone has a suggestion for how to get the replies in the other forum (if that is where they belong) then I will do the best I can.

Adam Maccabee Trachtenberg

21 years ago
On Sun, 19 Sep 2004, Sam Hobbs wrote:
> I think it is reasonable to ask for the one or two lines of PHP code that > solves the problem. As I have said, I did try to do it myself.
foreach ($ContentsDocument->childNodes as $Node) { $n = $Document->importNode($Node, true); $Cell->appendChild($n); } -adam
-- adam@trachtenberg.com author of o'reilly's "upgrading to php 5" and "php cookbook" avoid the holiday rush, buy your copies today!

Sam Hobbs

21 years ago
"Adam Maccabee Trachtenberg" <adam@trachtenberg.com> wrote in message news:Pine.LNX.4.58.0409191856080.16894@miranda.org...
> > foreach ($ContentsDocument->childNodes as $Node) { > $n = $Document->importNode($Node, true); > $Cell->appendChild($n); > }
Wow! Wonderful! That sure seems to work. That seems to be all I needed. I sure don't understand why I was not able to get that to work; I am sure I tried it, but perhaps I made a mistake that I overlooked. It sure is easy enough; I should have figured it out myself. Again, I really don't know why I did not figure it out myself. I am sorry for all the trouble.