Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8165281
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T19:29:59+00:00 2026-06-06T19:29:59+00:00

Documentation for data.xml/parse says The data is returned as defrecords and can be manipulated

  • 0

Documentation for data.xml/parse says

The data is returned as defrecords and can be manipulated using the normal clojure data structure functions.

Can the structure of those defrecords be inferred manually or programmatically, and, if so, how?

Here is the example in the docs compacted somewhat:

(let [input-xml (java.io.StringReader. 
                 "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
                 <foo><bar><baz>The baz value</baz></bar></foo>")]
  (parse input-xml))

#clojure.data.xml.Element{:tag :foo,
                      :attrs {},
                      :content 
(
#clojure.data.xml.Element{:tag :bar, 

:attrs {},
:content (#clojure.data.xml.Element{:tag :baz,
         :attrs {},
         :content ("The baz value")})})}
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T19:30:01+00:00Added an answer on June 6, 2026 at 7:30 pm

    In general, defrecords can be operated on as maps, because that is essentially what they are.

    For example:

    problems.core=> (defrecord Dog [name collarsize])
    

    Now, we have defined a defrecord type, a Dog.

    problems.core=> (keys (Dog. "laly" 1))           
    (:name :collarsize)
    

    So clearly, the “keys” function, which we all know and love for operating on maps, works fine.

    But to take it further, we find that a defrecord, alas, is truly a map :

    problems.core=> (map? (Dog. "laly" 1))           
    true
    

    So — why all this fuss over a simple map ? Because, since xml has a well-defined structure, it makes sense that we can have some gauranteed keys in every defrecord returned. In particular, the defrecord elements ill each have “:tag, :attrs, and :content”. To confirm, you can note thatthese constant defrecord attributes are always present in the online tutorials of parsing xml with clojure (i.e. http://www.gettingclojure.com/cookbook:xml-html ).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Where can I find some good documentation on data/element binding? My Google searches haven't
The example in doc http://www.rebol.org/documentation.r?script=rebelxml.r to create XML works >> clear-xml-data == >> set-xml-data/content
I'm attempting to gather XML data automatically using curl, and my command so far
I'm trying to parse XML data stored in a variable, not a file. The
I can't figure out what an InputStream is in the context of the clojure-xml
While there is plenty of documentation about XML document structure, there are very few
I'm using the XMLStreamReader interface from javax.xml to parse an XML file. The file
Going through some documentation on modifying CGImageRef data, I came across a strange example
I have to submit subscription data to another website. I have got documentation on
According to the UIImage documentation : In low-memory situations, image data may be purged

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.