XML-Twig

 view release on metacpan or  search on metacpan

Changes  view on Meta::CPAN


- improved: updated the doc so it can be properly formatted by my custom pod2html,
  the generated doc (with a bigger ToC and better links) is available
  from the XML::Twig page at http://xmltwig.com/xmltwig/
  
  
3.09 - 2002-11-10 

- added: XML::Twig::Elt xml_text method

- fixed: several bugs in the split method under 5.8.0 when matching a utf8
  character (thanks to Dominic Mitchell who spotted them)

- improved: cleaned-up the pod (still in progress)

- added: the XML::Twig::Elt pos method that gives the position of
  an element in its parent's child list

- fixed: re-introduced parseurl (thanks to Denis Kolokol for spotting its 
  absence in this version)

Changes  view on Meta::CPAN

  if the option is not a valid one);

- improved: when using pretty_print nice or indented keep_spaces_in is now checked
  so the elements within an element listed in keep_spaces_in are not
  indented

- added: XML::Twig::Elt insert_new_elt method that does a new and a paste

- added: XML::Twig::Elt split_at method splits a #PCDATA element in 2

- added: XML::Twig::Elt split method splits all the text descendants of an 
   element, on a regep, wrapping text captured in brackets in the
   regexp in a specified element, all elements are returned 

- added: XML::Twig::Elt mark method is similar to the split method, except
  that only newly created elements (matched by the regexp) are
  returned

- added: XML::Twig::Elt get_type method returns #ELT for elements and the gi
  (#PCDATA, #CDATA...) otherwise

- added: XML::Twig::Elt is_elt returns the gi if the element is a real element
  and 0 if it is #PCDATA, #CDATA...
  
- added: XML::Twig::Elt contains_only_text returns 1 if the element contains no

lib/XML/Twig.pm  view on Meta::CPAN

          else
            { push @tags, { tag => $tag }; }
        }

      unless( @tags) { @tags= { tag => $elt->_parent->gi }; }

      my @result;                                 # the returned list of elements
      my $text= $elt->text;
      my $gi= $elt->gi;

      # 2 uses: if split matches then the first substring reuses $elt
      #         once a split has occurred then the last match needs to be put in
      #         a new element
      my $previous_match= 0;

      while( my( $pre_match, @matches)= $text=~ /^(.*?)$regexp(.*)$/gcs)
        { $text= pop @matches;
          if( $previous_match)
            { # match, not the first one, create a new text ($gi) element
              $elt= $elt->insert_new_elt( after => $gi, $pre_match);
              push @result, $elt if( $return_all);

lib/XML/Twig.pm  view on Meta::CPAN


  sub _replace_var
    { my( $string, @var)= @_;
      unshift @var, undef;
      $string=~ s{\$(\d)}{$var[$1]}g;
      return $string;
    }

  sub _install_replace_sub
    { my $replace_exp= shift;
      my @item= split m{(&e[ln]t\s*\([^)]*\))}, $replace_exp;
      my $sub= q{ my( $match, @var)= @_; my $new; my $last_inserted=$match;};
      my( $gi, $exp);
      foreach my $item (@item)
        { next if ! length $item;
          if(    $item=~ m{^&elt\s*\(([^)]*)\)})
            { $exp= $1; }
          elsif( $item=~ m{^&ent\s*\(\s*([^\s)]*)\s*\)})
            { $exp= " '#ENT' => $1"; }
          else
            { $exp= qq{ '#PCDATA' => "$item"}; }



( run in 1.060 second using v1.01-cache-2.11-cpan-71847e10f99 )