stefzody has asked for the wisdom of the Perl Monks concerning the following question:
Anyway, I have a parser running and my XML, and i am trying to put options into a select box, using values that I have in a database. I can get the data out and finding the correct select to 'replace' or update with the options.
I have managed to get some code that looks roughly as follows:
my @list = $tree->findnodes('//select[@id="categoryID"]') || warn "cou +ldnt find any nodes for select & name of categoryID"; while (my $row=$cat_sth->fetchrow_hashref ) { my $node = XML::LibXML::Element->new('option'); $node->setAttribute('value',$row->{id}); if ($row->{id} == $params->{categoryID}) { $node->setAttribute('selected','selected'); } my $text = XML::LibXML::Text->new($row->{description}); $node->appendChild($text); $list[0]->push($node);
Now, the obvious question is, what am i doing wrong ? When the page is printed out, none of the other values that i put in present. (Yes, i have also made sure that the values are retrieved from the database, i think this is more a 'misunderstanding' of NodeLists, XML::LibXML and how to add new nodes into it)
thanks
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: LibXML 'Fun'
by dws (Chancellor) on Oct 12, 2003 at 00:23 UTC | |
by stefzody (Acolyte) on Oct 12, 2003 at 00:43 UTC | |
by dws (Chancellor) on Oct 12, 2003 at 01:07 UTC | |
by stefzody (Acolyte) on Oct 12, 2003 at 01:56 UTC | |
by dws (Chancellor) on Oct 12, 2003 at 03:31 UTC | |
|
Re: LibXML 'Fun'
by delirium (Chaplain) on Oct 12, 2003 at 00:57 UTC |