Menu

#1 missing a XML::Mini::Element method to set text

open
nobody
None
5
2003-03-31
2003-03-31
D.H.
No

Currently there is no way to effectively
set the text value of a XML::Mini::Element.

->text as you know only APPENDS.

There is no way to get at the nodes
through the API
(i consider this a major design flaw)

A remedy might be to provide the following methods
insertNode
prependNode
removeNode
removeAllNodes
getAllNodes

The following already exist.
createNode
appendNode

These should be trivial to implement.
Here's the perl implementation
(My cpanid is PODMASTER)

sub insertNode {
splice @{ $_[0]->{_children} }, $_[1], 0, $_[2];
return $_[2];
}

sub prependNode {
unshift @{ $_[0]->{_children} }, $_[1];
return $_[1];
}

sub removeNode {
return splice @{ $_[0]->{_children} }, $_[1], 1;
}

sub removeAllNodes {
my $kids = $_[0]->{_children};
$_[0]->{_children} = [];
return $kids;
}

sub getAllNodes {
return $_[0]->{_children};
}

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.