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
In reply to LibXML 'Fun' by stefzody
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |