in reply to Trying to use XML::Twig

To find out how many product are in $nameyou can just do my $nb_product= $name->children( 'product'); (that's children in scalar context, in list context you would of course get the list of product children).

As for the name space question could you please explain a little more what you want to do and what you have tried so far, I am pretty sure there is nothing about name spaces in the XML::Twig documentation.

This post brought to you courtesy of tonio

Replies are listed 'Best First'.
Re: Re: Trying to use XML::Twig
by Novitiatus (Novice) on Sep 21, 2001 at 21:41 UTC
    Thanks, I'm back from eating my gruel...
    http://www.standards.ieee.org/resources/spasystem/twig/twig_dev.html
    That is where I saw the
    within_element($gi) Call Expat within_element method. Returns the number of times the given name appears in the context list. If namespace processing is being used and you want to check against a name that may be in a namespace, then use the generate_ns_name method to create the $gi argument. Usefull when using the TwigRoots option.

      Consider this a bad case of cut'n paste. The doc for within_element is from the original XML::Parser::Expat method. In fact this method should only be used during the parsing, if you are using the twig_roots option, to get information about the original document, not the view on it defined by twig_roots... if that makes any sense.

      Basically you should use $elt->ancestors( $gi) in scalar context to getthe number of ancestors of type $gi for the element $elt. Which does not look like what you wanted anyway ;--(

      Thanks for letting me know about this silly documentation bit though, I will fix it in the next release.