in reply to Altering values in XML-mini

The documentation seems perfectly clear to me ... here's an example
use XML::Mini::Document; my $newDoc = XML::Mini::Document->new(); my $root = $newDoc->getRoot(); my $header = $root->header('xml'); # set the header $header->attribute('version', '1.0'); my $kid = $root->createChild('foo'); $kid->text("Yes, I am a kid"); $root->createChild('foo')->text('Me Too'); print $newDoc->toString(); __END__ <?xml version="1.0"?> <foo> Yes, I am a kid </foo> <foo> Me Too </foo>
Holler if this ain't clear for you, but be sure to provide more context (and show that you've read the documentation, cause the documentation is thorough).

update: I can see now (through ESP) how you might be confused. The text methods APPENDS (appends) values to an element. The only way to get at the XML::Mini::Node's is to cheat and look at an XML::Mini::Element's _children attribute. The XML::Mini API is thus flawed and for no apparent reason.

update: I've added this to Feature Requests.
[ 712722 ] missing a XML::Mini::Element method to set text

package XML::Mini::Element; 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}; }


MJD says you can't just make shit up and expect the computer to know what you mean, retardo!
I run a Win32 PPM repository for perl 5.6x+5.8x. I take requests.
** The Third rule of perl club is a statement of fact: pod is sexy.

Replies are listed 'Best First'.
Re: Re: Altering values in XML-mini
by AndyH (Sexton) on Mar 31, 2003 at 16:36 UTC

    update: I can see now (through ESP) how you might be confused. The text methods APPENDS (appends) values to an element. The only way to get at the XML::Mini::Node's is to cheat and look at an XML::Mini::Element's _children attribute.

    Which is what I have been doing for the re-ordering and attribute changing. I just haven't figured out the appropriate wizardry to do remove an element or add an element.

    Also, I'm not clear if the code you posted is how you want XML::Mini to work or if that's the _children workaround I'm looking for ...

    A.