XML-API

 view release on metacpan or  search on metacpan

README  view on Meta::CPAN

    your element names are not suitable as Perl method calls, or are
    otherwise funny (eg starting with '_').

  $x->element(-attribute => $value, {attr2 => 'val2'}, $content)
    Add a new element to the 'current' element but keep the 'current'
    element the same. Returns a reference (private data type) to the new
    element which can be used in the _goto function below.

    This is effectively the same as the following:

        $x->element_open(-attribute => $value, -attr2=>'val2');
        $x->_add($content);
        $x->element_close;

    If $content is not given (or never added with the _add method) for an
    element then it will be rendered as empty. Ie, $x->br() produces:

        <br />

  $x->_element('element',...)
    The generic implementation of $x->element. Useful if your element names
    are not suitable as Perl method calls, or are otherwise funny (eg
    starting with '_').

  $x->element_raw('raw content',...)
    Adds unescaped content inside an element named 'element'. This is a
    shortcut for the case where you find yourself doing the following:

        $x->element_open();
        $x->_raw($content);
        $x->element_close();

  $x->ns__element_open(...)
    Same as $x->element_open but prefixed with an XML namespace. Equivalent
    to the following.

      $x->_ns('ns');
      $x->element_open(...);
      ...
      $x->element_close;
      $x->_ns(undef);

  $x->ns__element(...)
    Same as $x->element but prefixed with an XML namespace. Equivalent to
    the following.

      $x->_ns('ns');
      $x->element(...);
      $x->_ns(undef);

  $x->_comment($comment)
    Add an XML comment to $x. Is almost the same as this:

        $x->_raw("\n<!--");
        $x->_raw($content);
        $x->_raw('-->')

    Except that indentation is correct. Any occurences of '--' in $content
    will be replaced with '- -'.

  $x->_cdata($content)
    A shortcut for $x->_raw("\n<![CDATA[", $content, " ]]>");

  $x->_css($content )
    Adds $content inside a pair of CDATA tags which are encapsulated inside
    CSS comments. Similar to:

     $x->_raw('/*<![CDATA[*/ '. $content .' /*]]>*/');

  $x->_javascript($script )
    A shortcut for adding $script inside a pair of <script
    type="text/javascript"> elements and a _CDATA tag.

  $x->_parse(@content)
    Adds content to the current element, but will parse it for xml elements
    and add them as method calls. Regardless of $content (missing end tags
    etc) the current element will remain the same. Relies on XML::SAX to do
    the parsing using the "parse_string" method. In this case XML::SAX
    requires that the content is a complete xml document.

  $x->_parse_chunk(@content)
    Adds content to the current element, but will parse it for xml elements
    and add them as method calls. Regardless of $content (missing end tags
    etc) the current element will remain the same. Relies on XML::SAX to do
    the parsing, but using the "parse_chunk" method. This method is suitable
    for parsing xml fragments which are not necessarily complete.

  $x->_ast(@content)
    Sometimes you may want to just build some kind of abstract syntax tree
    structure and just feed it to XML::API without having to make all the
    method calls yourself. This method lets you do just that.

    The following input:

      p => [
          label => 'Body',
          textarea => [
              -rows  => 10,
              -cols  => 50,
              -name  => 'body',
              'the body',
          ],
      ],

    results in the following xml:

      <p>
        <label>Body</label>
        <textarea cols="50" name="body" rows="10">the body</textarea>
      </p>

  $x->_attrs( )
    Allows you to get/set the attributes of the current element. Accepts and
    returns and hashref.

META DATA
  $x->_encoding($value)
    Set the encoding definition produced in the xml declaration. Returns the
    current value if called without an argument. This is an alternative to
    defining the encoding in the call to 'new'.



( run in 0.526 second using v1.01-cache-2.11-cpan-6aa56a78535 )