Greetings monks, ye great and powerful...

Every now and again I have to deal with some XML (as much as I hate the stuff) and I pretty much always cludge it. Sometimes I'll use XML::Simple, or other times I'll just use some regexes. I think it's about time I learned how to handle it properly. I'll describe my present problem, but please keep in mind that I really want general XML guidance.

I'm working with Google's contacts API and when you edit a contact, you need to not only parse the blob of XML but you have to edit it and return the whole thing or the contact gets screwed up. IE, it overwrites the existing contact with the contents of the returned XML blob. So, I need to be able to read some XML, turn it into useful data structures and then turn it back into the same XML with a few values changed.(If you've never worked with XML, that's not easily done because XML does not map directly to data structures the way that, say JSON and YAML do. So, you can't convert an arbatrary data structure into XML and assume another XML implementation would produce the same XML.) XML does have things like a DTD (which I've never used).

To summarize, I need to be able to convert XML into data and back to XML preserving the XML format (not sure if format is the word here... layout?). I think DTD's might be involved, but I don't know how to use them. I'm working with a Google API which uses ATOM feeds, but I really want more general advice that will apply to XML that isn't a Google API ATOM feed. What i'd really like is recommendations of perl modules that can turn XML to data and back again without breaking the XML and links to web pages that tell me why it works the way it does.

Thank you all for wasting your time reading this and possibly even helping me.

--Pileofrogs


In reply to Getting started with XML by pileofrogs

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.