Hi guys,

Thank you for your quicky replies. I think I found what's wrong inside xml document. It seems that only if a link contains character '&' then the parser reports an error.

For example, <link r:resource="http://www.urbancinefile.com.au/home/article_view.asp?Article_ID=3801&Section=Reviews"/>

As I need to read <link/> elements one by one and compare the attribute value with user's input, my new question is, how can I overcome this '&' problem? I have tried to use '\' before '&' but it doesn't work.

Thanks again,

sub topic {
my $count = 0;
my ($twig, $topic) = @_;
$links{$_->att('r:resource')} = $_ for $topic->children('link');
foreach my $key (keys %links){
if ($key =~ /$q/i){
print "
  • ", $topic->att('r:id'), "
  • \n";
    $count++;
    }
    last if ($count == 1); #if keywords were found in one link, we don't need to check the others in the same node, because we aim to output parent category only.
    }
    print "\n";
    $twig->purge;
    %links = (); #reset the hash for next time use
    }
    Nan

    In reply to Re^2: Why XML not well formed? by nan
    in thread Why XML not well formed? by nan

    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.