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 6235989
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T10:46:23+00:00 2026-05-24T10:46:23+00:00

I recently wrote the following Python function which will take a Google Picasa contacts.xml

  • 0

I recently wrote the following Python function which will take a Google Picasa contacts.xml file and output a dictionary with ID and Name.

def read_contacts_file(fn):
    import xml.etree.ElementTree
    x = xml.etree.ElementTree.ElementTree(file=fn)
    q = [(u.attrib["id"], u.attrib["name"]) for u in x.iter("contact")]
    return dict(q)

What this function does is return a dictionary (hashtable, map) with the ID being the key and the Name being the value.

The file itself has the form:

<contacts>
 <contact id="f5fdaaee2e80fa01" name="Person A" display="A"/>
 <contact id="8d5256298fd43877" name="Person B" display="B"/>
</contacts>

What’s the simplest way I can implement this in Haskell?


Just wanted to let you know that with everyone’s help, I’ve managed to come up with the following which makes sense to me. Thanks.

parseContactsData = M.fromList . runLA (xread >>> f) 
    where f = 
        getChildren 
        >>> hasName "contact" 
        >>> getAttrValue "id" &&& getAttrValue "name"
  • 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-05-24T10:46:24+00:00Added an answer on May 24, 2026 at 10:46 am

    Here’s an example doing it with HXT

    import Text.XML.HXT.Core
    import Data.Map
    
    idAssocs = hasName "contact" >>> getAttrValue "id" &&& getAttrValue "name"
    dict = fromList `fmap` runX (readDocument [] "contacts.xml" >>> deep idAssocs)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I recently wrote a function template which takes a reference to a C-array: template
I recently wrote a parser in Python using Ply (it's a python reimplementation of
I recently wrote a DLL in C# (.Net 2.0) which contains a class that
I recently wrote a class for an assignment in which I had to store
I recently wrote a piece of code which did SomeClass someObject; mysqlpp::StoreQueryResult result =
I have a Python script I recently wrote that I call using the command
Recently I wrote a function to generate certain sequences with nontrivial constraints. The problem
Recently I've spotted a very disturbing issue. I've got the following python code: for
I recently wrote the following selector with a little help from (possbily you) StackOverflow
Recently, after being very tired, I wrote the following code: GLfloat* array = new

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.