in reply to Create Mixed Content with XML::LibXML

I see no "mixed content" node.

What I see is a head element that has three child elements, the first child and the third child are term elements, the second child is a #text element. Both term elements have one #text child element each.

And this is exactly how you would create it with XML::LibXML. Create the root element, create child elements, append the elements, create text nodes, append them to the parent nodes (Hint: shortcut methods appendText() and appendTextChild()).

Alexander

--
Today I will gladly share my knowledge and experience, for there are no sweeter words than "I told you so". ;-)

Replies are listed 'Best First'.
Re^2: Create Mixed Content with XML::LibXML
by ikegami (Patriarch) on Apr 13, 2011 at 17:33 UTC

    As code:

    my $term1 = XML::LibXML::Element->new('term'); $term1->appendTextNode('Einführung'); my $term2 = XML::LibXML::Element->new('term'); $term2->appendTextNode('Soziologie'); my $head = XML::LibXML::Element->new('head'); $head->addChild($term1); $head->appendTextNode(' in die '); $head->addChild($term2);

    (Pay attention to the notes for addChild in the docs.)

      thank you both, i didn't know i could just add a text node inbetween those two nodes. thanks a lot!