First all, thanks, those are great suggestions, I didn't know about the setNamespace trick for defining context, however I still have to redefine it for every level as I progress through the xml right? Perhaps I'm not being clear. Incomming example:
<root xmls='urn:foo'> <first_sub name='foo'> <second_sub id='1'> <third_sub>Foo</third_sub> </second_sub> <second_sub id='2'> </second_sub> </first_sub> </root>
Now just imagine that there are multiple first_sub, second_sub, and third_sub elements nested in the example above. In order to get at all the values I want, as far as I can tell I have to do something like this(assuming $xml is set to the above):
my $parser = XML::LibXML->new(); my $data = $parser->parse_string ( $xml ); $data->setNamespace ( 'urn:foo', 'x' ); for my $first_sub ( $data->findnodes ('/x:root/x:first_sub')) { my $name = $first_sub->getAttribute('name'); $first_sub->setNamespace ('urn:foo','x'); for my $second_sub ( $first_sub->findnodes ('./x:second_sub')) { my $id = $second_sub->getAttribute('id'); $second_sub->setNamespace ('urn:foo','x'); for my $third_sub ( $second_sub->findnodes('./x:third_sub')) { # do something with the values } } }
So I'm pretty sure its confirmed that I can't remove the name space to avoid all this setting/defining and extra work in the XPath expressions, which was my original question, this is fine, I'll just stick to something like the above. thanks again.

In reply to Re^2: LibXML - Removing Namespace? by Anonymous Monk
in thread LibXML - Removing Namespace? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.