NAME
    XML::Chain - chained way of manipulating and inspecting XML documents
SYNOPSIS
        use XML::Chain qw(xc);
    
        # basics
        my $div = xc('div', class => 'pretty')
                    ->c('h1')->t('hello')
                    ->up
                    ->c('p', class => 'intro')->t('world')
                    ->root
                    ->a( xc('p')->t('of chained XML.') );
        say $div->as_string;
        # 
hello
world
of chained XML.
and
head
')
                ->find('//h1')->count
  xc($scalar)
    Element with $scalar will be create as document element.
        say xc('body');
CHAINED METHODS, METHODS and ELEMENT METHODS
    See XML::Chain::Selector and XML::Chain::Element.
CHAINED DOCUMENT METHODS
        xc('body')->t('save me')->set_io_any([$tmp_dir, 't01.xml'])->store;
        # $tmp_dir/t01.xml file now consists of:
            save me
        xc([$tmp_dir, 't01.xml'])->empty->c('div')->t('updated')->store;
        # $tmp_dir/t01.xml file now consists of:
            updated
 set_io_any
    Store  $what , $options  of IO::Any for future use with  ->store() 
 store
    Calls  IO::Any-spew($io_any, $self->as_string, {atomic => 1}) > to save
    XML back it it's original file of the the target set via set_io_any.
TODO
        - partial/special tidy (on elements inside xml)
        - per ->data() storage
        - ->each(sub {...}) / ->map(sub {}) / ->grep(sub {})
        - setting and handling namespaces and elements with ns prefixes
        - ~ton of selectors and manipulators to be added
CONTRIBUTORS & CREDITS
    Initially inspired by Strophe.Builder, then also by jQuery.
    The following people have contributed to the XML::Chain by committing
    their code, sending patches, reporting bugs, asking questions,
    suggesting useful advice, nitpicking, chatting on IRC or commenting on
    my blog (in no particular order):
        Slaven Rezic
        Vienna.pm (for listening to my talk and providing valuable feedback)
        Mohammad S Anwar
        you?
    Also thanks to my current day-job-employer http://geizhals.at/.
BUGS
    Please report any bugs or feature requests via
    https://github.com/meon/XML-Chain/issues.
AUTHOR
    Jozef Kutej
COPYRIGHT & LICENSE
    Copyright 2017 Jozef Kutej, all rights reserved.
    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.
----------------------------------------------------------------------------
NAME
    XML::Chain::Selector - selector for traversing the XML::Chain
SYNOPSIS
        my $user = xc('user', xmlns => 'http://testns')->auto_indent({chars=>' 'x4})
            ->a('name', '-' => 'Johnny Thinker')
            ->a('username', '-' => 'jt')
            ->c('bio')
                ->c('div', xmlns => 'http://www.w3.org/1999/xhtml')
                    ->a('h1', '-' => 'about')
                    ->a('p', '-' => '...')
                    ->up
                ->a('greeting', '-' => 'Hey')
                ->up
            ->a('active', '-' => '1')
            ->root;
        say $user->as_string;
    Will print:
        
            Johnny Thinker
            jt
            
                
                Hey
            
            1
        
DESCRIPTION
CHAINED METHODS
 c, append_and_select
    Appends new element to current elements and changes context to them.
    New element is defined in parameters:
        $xc->c('i', class => 'icon-download icon-white')
        # 
    First parameter is name of the element, then followed by optional
    element attributes.
 t, append_text
    Appends text to current elements.
        xc('span')->t('some')->t(' ')->t('more text')
        # some more text
    First parameter is name of the element, then followed by optional
    element attributes.
 root
    Sets document element as current element.
        say xc('p')
            ->t('this ')
            ->a(xc('b')->t('is'))
            ->t(' important!')
            ->root->as_string;
        # this is important!
 up, parent
    Traverse current elements and replace them by their parents.
 find
        say $xc->find('//p/b[@class="less"]')->text_content;
        say $xc->find('//xhtml:div', xhtml => 'http://www.w3.org/1999/xhtml')->count;
    Look-up elements by xpath and set them as current elements. Optional
    look-up namespace prefixes can be specified. Any global registered
    namespace prefixes "reg_global_ns" can be used.
 children
    Set all current elements child nodes as current elements.
 first
    Set first current elements as current elements.
 empty
    Removes all child nodes from current elements.
 rename
        my $body = xc('bodyz')->rename('body');
        # 1
2
3
4
','rename using each()');
    Loops through all selected elements and calls callback for each of
    them.
 remap
        xc('body')->a('p', i => 1)->children->remap(
            sub {
                (map {xc('e', i => $_)} 1 .. 3), $_;
            }
        )->root;
        # 
    Replaces all selected elements by callback returned elements.
 rm, remove_and_parent
        my $pdiv = xc('base')
                ->a(xc('p')->t(1))
                ->a(xc('p')->t(2))
                ->a(xc('div')->t(3))
                ->a(xc('p')->t(4));
        my $p = $pdiv->find('//p');
        # $pdiv->find('//p[position()=3]')->rm->name eq 'base'
        # $p->count == 2     # deleted elements are skipped also in old selectors
        # 1
2
3
    Deletes current elements and returns their parent.
 auto_indent
    (experimental feature (good/usefull for debug, needs more testing),
    works only on element for which as_string is called at this moment)
        my $simple = xc('div')
                        ->auto_indent(1)
                        ->a('div', '-' => 'in1')
                        ->a('div', '-' => 'in2')
                        ->t('in2.1')
                        ->a('div', '-' => 'in3')
        ;
        say $simple->as_string;
    Will print:
        
    Turn on/off tidy/auto-indentation of document elements. Default
    indentation characters are tabs.
    Argument can be either true/false scalar or a hashref with indentation
    options. Currently	{chars=' 'x4} > will set indentation characters to
    be four spaces.
CHAINED DOCUMENT METHODS
    See "CHAINED DOCUMENT METHODS" in XML::Chain.
METHODS
 as_string, toString
    Returns string representation of current XML elements. Call root before
    to get a string representing the whole document.
        $xc->as_string
        $xc->root->as_string
 as_xml_libxml
    Returns array of current elements as XML::LibXML objects.
 text_content
    Returns text content of all current XML elements.
 count / size
        say $xc->find('//b')->count;
    Return the number of current elements.
 single
        my $lxml_el = $xc->find('//b')->first->as_xml_libxml;
    Checks is there is exactly one element in current elements and return
    it as XML::Chain::Element object.
 reg_global_ns
        $sitemap->reg_global_ns('i' => 'http://www.google.com/schemas/sitemap-image/1.1');
        $sitemap->reg_global_ns('s' => 'http://www.sitemaps.org/schemas/sitemap/0.9');
        say $sitemap->find('/s:urlset/s:url/i:image')->count
        # 2
AUTHOR
    Jozef Kutej
COPYRIGHT & LICENSE
    Copyright 2017 Jozef Kutej, all rights reserved.
    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.
----------------------------------------------------------------------------
NAME
    XML::Chain::Element - helper class for XML::Chain representing single
    element
SYNOPSIS
        xc('body')->c(h1)->t('title')->root
DESCRIPTION
    Returned by "single" in XML::Chain::Selector call.
METHODS
 name
    return element name
 as_xml_libxml
    Returns XML::LibXML::Element object.
 XML::Chain::Selector methods
    All of the XML::Chain::Selector methods works too.
AUTHOR
    Jozef Kutej
COPYRIGHT & LICENSE
    Copyright 2017 Jozef Kutej, all rights reserved.
    This program is free software; you can redistribute it and/or modify it
    under the same terms as Perl itself.