Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re^2: Kindly suggest a good starting point for XML Parsing.

by choroba (Abbot)
on Dec 30, 2011 at 00:45 UTC ( #945575=note: print w/ replies, xml ) Need Help??


in reply to Re: Kindly suggest a good starting point for XML Parsing.
in thread Kindly suggest a good starting point for XML Parsing.

Can you be more specific? Are you talking about escaping control characters? Is your example correct?

use XML::LibXML; $s = "&ltfoo name=bobby>&ltname&gtrobert</name></foo></p>"; print "before: $s.\n"; $dom = XML::LibXML->load_xml(string => "<root/>"); $dom->findnodes("/root")->[0]->appendText($s); print $dom->serialize; $s2 = $dom->findnodes("//text()")->[0]->data; print "after: $s2.\n";
Output:
before: &ltfoo name=bobby>&ltname&gtrobert</name></foo></p>. <?xml version="1.0"?> <root>&amp;ltfoo name=bobby&gt;&amp;ltname&amp;gtrobert&lt;/name&gt;&l +t;/foo&gt;&lt;/p&gt;</root> after: &ltfoo name=bobby>&ltname&gtrobert</name></foo></p>.


Comment on Re^2: Kindly suggest a good starting point for XML Parsing.
Select or Download Code
Re^3: Kindly suggest a good starting point for XML Parsing.
by pileofrogs (Priest) on Jan 03, 2012 at 22:26 UTC

    I probably should have put that in code tags instead of using all those &lt, &gt. Sorry.

    <foo name=bobby><name>robert</name></foo>

    My point is, your foo has two names.

    <foo name=bobby><age>27</age></foo>

    Also sucks. It's no different from

    <foo age=27><name>bobby</name></foo>

    Obviously it's different, but not in a truly meaningful way. You could just as easily say

    <foo age=27 name=bobby></foo>

    or

    <foo><age>27</age><name>bobby</name></foo>
      I got it. From this point of view, you are right. You did not mention
      <foo> <name>Robert</name> <name>Bobby</name> </foo>
      But you can view it inside out: data types suck, because they cannot easilly represent XML :-)

        ++

        Good point! Very Zen.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://945575]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (6)
As of 2014-09-24 00:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (243 votes), past polls