# Copying HTML from a document to another document

- Thread: https://externals.io/message/12901
- Original archive: https://news-web.php.net/php.internals/12901
- Started by Sam Hobbs on 2004-09-19T18:30:49+00:00
- Messages: 11
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #12901 — Sam Hobbs — 2004-09-19T18:30:49+00:00

URL: https://externals.io/message/12901#12901

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.?

---

## #12902 — Christian Stocker — 2004-09-19T18:37:17+00:00

URL: https://externals.io/message/12901#12902 · In reply to: #12901

> 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

---

## #12903 — Sam Hobbs — 2004-09-19T19:38:25+00:00

URL: https://externals.io/message/12901#12903 · In reply to: #12902

"Christian Stocker" <chregu@bitflux.ch> wrote in message 
news:414DD1DD.80205@bitflux.ch...
>
>
> 
> > […]
>
> 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.

---

## #12904 — dharana — 2004-09-19T19:43:48+00:00

URL: https://externals.io/message/12901#12904 · In reply to: #12903

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

---

## #12905 — Sam Hobbs — 2004-09-19T20:53:03+00:00

URL: https://externals.io/message/12901#12905 · In reply to: #12904

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...
> http://www.catb.org/~esr/faqs/smart-questions.html
>
> > […]

---

## #12906 — Christian Stocker — 2004-09-19T20:54:24+00:00

URL: https://externals.io/message/12901#12906 · In reply to: #12903

> "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.

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

---

## #12907 — Rasmus Lerdorf — 2004-09-19T21:16:40+00:00

URL: https://externals.io/message/12901#12907 · In reply to: #12905

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

---

## #12908 — Sam Hobbs — 2004-09-19T21:30:03+00:00

URL: https://externals.io/message/12901#12908 · In reply to: #12906

"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.

---

## #12909 — Sam Hobbs — 2004-09-19T21:52:25+00:00

URL: https://externals.io/message/12901#12909 · In reply to: #12907

"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.

---

## #12910 — Adam Maccabee Trachtenberg — 2004-09-19T23:00:56+00:00

URL: https://externals.io/message/12901#12910 · In reply to: #12908

> 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!

---

## #12911 — Sam Hobbs — 2004-09-20T03:58:56+00:00

URL: https://externals.io/message/12901#12911 · In reply to: #12910

"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.
