The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

XML::XMLWriter::Element - XML::XMLWriter Element Class

In General

Down there are some methods which to you might seem quite useless since they simply call some other expression which you could also call directly. I recommend to use them though since in feature releases they might do more and then you surley don't want to modify your code. I just document what they call to make clear what they do so far.

Methods

new ($elementname, $ParseDTD_object, \%arguments, $pcdata, $Element_parent_object)

Constructor. Complains by outputting a warning if the attribute list or some attribute value is not allowed by the DTD.

_text (@pcdata)

Same as _pcdata.

_pcdata (@pcdata)

Adds a XML::XMLWriter::PCData object to the child list. But returns the elements object ($self). See the POD of PCData.pm for more information on what is done with @pcdata.

_entity ($ref)

Simply calls and returns _cdata('&$ref;');.

_comment ($comment)

Simply calls and returns _cdata('<!-- $comment -->');.

_pi ($target, $data)

Adds an processing instruction to the child list by calling and returning _cdata('<?$target $data?>');.

_cdata (@cdata)

Simply adds every element that @cdata contains to the child list. You can also call directly _push_child(@cdata).

Returns the object it was called on.

_add ($element, \%arguments, $pcdata)

Adds element/tag $element to the child list. It'll produce a warning if the DTD doesn't allow that operation. Depending on whether the DTD says that the newly created element is a empty element or not, the object _add was called on or the newly created object is returned.

_parent ()

Returns the elements parent element object.

_get ()

Returns the XML code taking the element it is called on as root. This method works recursive. It checks every elements child list and complains if it is not allowed by the DTD.

_push_child (@childs)

Adds the elements of @childs to the objects child list. Returns 1.

AUTOLOAD (\%arguments, $pcdata);

If you call an undefined method on the object this method is called instead.

The name of the method that you tried to call will be taken as a tag resp. element name, then _add is called and returned, passing it the name as first argument (and forwarding the other arguments).

For every tag that starts with _ you have to add one _ more because one will be cutted of. That means that you've to call __foobar(..) to add a tag called _foobar.

If you don't like that, you can always call _add('yourtag', ..).

Please see _add for more information.