From: Andrew Ballard on
On Fri, May 14, 2010 at 12:04 AM, Nathan Nobbe <quickshiftin(a)gmail.com> wrote:
[snip]
> having said that if you wanted to append
> a new DOMNode to an existing one, you would use the appendChild() method.

Usually, yes. In this case, since she would be importing nodes from
one document into another document, she would need to use importNode()
instead of appendChild().

Andrew
From: Nathan Nobbe on
On Fri, May 14, 2010 at 7:20 AM, Andrew Ballard <aballard(a)gmail.com> wrote:

> On Fri, May 14, 2010 at 12:04 AM, Nathan Nobbe <quickshiftin(a)gmail.com>
> wrote:
> [snip]
> > having said that if you wanted to append
> > a new DOMNode to an existing one, you would use the appendChild() method.
>
> Usually, yes. In this case, since she would be importing nodes from
> one document into another document, she would need to use importNode()
> instead of appendChild().


right, if there was actually more than one document, which in this case
there isnt... whether or not there should be multiple DOMDocuments here is
about as unclear as OPs original question.

-nathan
From: Alice Wei on

Hi,

You are right about the fact I am not having multiple documents, and yet what I am trying to do here is to have one xmldoc, which I have declared in my original email, and have my other rss feeds that I am trying to call from the PHP to append as I check more checkboxes from the list.

Right now, when I check one box, it does present it the way I want it, which is open a new xmldoc, and print out the rss feed. Yet, when I try to check the second box, it gives me the display of the rss feed from the second and not the first, because the second one opens a new xmldoc.. However, I would like to see both docs in one screen, which is why I want to know if there is such a function available.

Is what I am trying to do here possibly by any chance?
Thanks for your help.

Alice

Date: Fri, 14 May 2010 08:26:48 -0600
Subject: Re: [PHP] Append Dom Document
From: quickshiftin(a)gmail.com
To: aballard(a)gmail.com
CC: ajwei(a)alumni.iu.edu; php-general(a)lists.php.net

On Fri, May 14, 2010 at 7:20 AM, Andrew Ballard <aballard(a)gmail.com> wrote:

On Fri, May 14, 2010 at 12:04 AM, Nathan Nobbe <quickshiftin(a)gmail.com> wrote:

[snip]

> having said that if you wanted to append

> a new DOMNode to an existing one, you would use the appendChild() method.



Usually, yes. In this case, since she would be importing nodes from

one document into another document, she would need to use importNode()

instead of appendChild().
right, if there was actually more than one document, which in this case there isnt... whether or not there should be multiple DOMDocuments here is about as unclear as OPs original question.

-nathan
_________________________________________________________________
The New Busy think 9 to 5 is a cute idea. Combine multiple calendars with Hotmail.
http://www.windowslive.com/campaign/thenewbusy?tile=multicalendar&ocid=PID28326::T:WLMTAGL:ON:WL:en-US:WM_HMP:042010_5
From: Andrew Ballard on
On Fri, May 14, 2010 at 1:14 PM, Alice Wei <ajwei(a)alumni.iu.edu> wrote:
>
> Hi,
>
>   You are right about the fact I am not having multiple documents, and yet what I am trying to do here is to have one xmldoc, which I have declared in my original email, and have my other rss feeds that I am trying to call from the PHP to append as I check more checkboxes from the list.
>
>   Right now, when I check one box, it does present it the way I want it, which is open a new xmldoc, and print out the rss feed. Yet, when I try to check the second box, it gives me the display of the rss feed from the second and not the first, because the second one opens a new xmldoc. However, I would like to see both docs in one screen, which is why I want to know if there is such a function available.
>
>   Is what I am trying to do here possibly by any chance?
>   Thanks for your help.
>
> Alice
>


Just move all of your DOMDocument code block inside the loop after the switch.

<?php

$q=$_GET["q"];
$q2 = explode(" ",$q);
$count = count($q2);

for($i=0;$i<$count;$i++) {

//find out which feed was selected
switch ($q2[$i]) {
case "Weather":
$xml=("http://rss.weather.com/rss/national/rss_nwf_rss.xml?cm_ven=NWF&cm_cat=rss&par=NWF_rss");
break;

case "NFL":
$xml = ("http://www.nfl.com/rss/rsslanding?searchString=home");
break;

default:
exit;
break;
}

$xmlDoc = new DOMDocument();
$xmlDoc->load($xml);

//get and output "<item>" elements
$x=$xmlDoc->getElementsByTagName('item');
for ($i=0; $i<=4; $i++)
{
$item_title=$x->item($i)->getElementsByTagName('title')
->item(0)->childNodes->item(0)->nodeValue;
$item_link=$x->item($i)->getElementsByTagName('link')
->item(0)->childNodes->item(0)->nodeValue;
$item_desc=$x->item($i)->getElementsByTagName('description')
->item(0)->childNodes->item(0)->nodeValue;

echo ("<p><a href='" . $item_link . "'>" . $item_title . "</a>");
echo ("<br />");
echo ($item_desc . "</p>");
}

}

?>

Andrew