I don't understand why you don't get same namespace every time

Anyway, If the XML are small and you need access to just a few nodes you could you XML::Simple, for example:

use XML::Simple; use strict; use warnings; my $xml = <<XML; <?xml version="1.0" standalone="yes"?> <sdnList> <sdnEntry> <lastName>Hello world !</lastName> </sdnEntry> </sdnList > XML my $xml1 = XMLin($xml);2 my $result = $xml1->{sdnEntry}->{lastName}; print "result:$result\n"; ; $xml = <<XML; <?xml version="1.0" standalone="yes"?> <sdnList xmlns="http://tempuri.org/sdnList.xsd" > <sdnEntry> <lastName>Hello world !</lastName> </sdnEntry> </sdnList > XML my $xml2 = XMLin($xml); $result = $xml1->{sdnEntry}->{lastName}; print "result:$result\n";

I've had performance problems using xpath queries, even it was faster to instantiate the document and consumed less memory than XML::Simple, overall it was slower accessing nodes ( which makes totally sense as XML::Simple returns a hash ).

My point is if you need a simple parser ( i.e: for config files or for consuming small services once a while ) I'd stick to XML::Simple. In environments of high volume or frequent parsing of huge XML documents I would use Expat instead it is really fast.


In reply to Re: how to get XML::LibXML perfect xpath query ? by bluescreen
in thread how to get XML::LibXML perfect xpath query ? by Kanishka.black0

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.