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

  • Home
  • SEARCH
  • 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 9086437
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:29:20+00:00 2026-06-16T21:29:20+00:00

I needed to parse an XML file in Haskell, so I chose HXT. I

  • 0

I needed to parse an XML file in Haskell, so I chose HXT. I like it so far, but I’m having trouble figuring out how to do one thing.

The file I’m parsing contains information as a config file. It has a structure similar to

<clients>
    <client>
        <name>SomeName</name>
        <info>MoreInfo</info>
        <table>
            <row>
                <name>rowname1</name>
                <value>rowvalue1</value>
            </row>
            <row>
                <name>rowname2</name>
                <value>rowvalue2</value>
            </row>
        </table>
    </client>
    ...
</clients>

This markup format makes me cringe, but it’s what I have to work with.

I have records for each of these in Haskell as follows

data Client = Client { name :: String, info :: String, table :: Table }
data Row = Row { name :: String, value :: String }
type Table = [Row]

And I want to get the data out of the file as a list of Clients. My current code looks like

data Client = Client { name :: String, info :: String, table :: Table }
data Row = Row { name :: String, value :: String }
type Table = [Row]

getClients = atTag "client" >>>
    proc client -> do
        name <- childText "name" -< client
        info <- childText "info" -< client
        table <- getTable <<< atTag "table" -< client

        returnA -< Client name info table
    where
        atTag tag = isElem >>> hasName tag
        atChildTag tag = getChildren >>> atTag tag
        text = getChildren >>> getText
        childText tag = atChildTag tag >>> text

        getTable = atChildTag "row" >>>
            proc row -> do
                name <- childText "name" -< row
                value <- childText "value" -< row
                returnA -< Row name value

But it doesn’t compile because it only gets a single Row back from getTable, instead of a list of Rows. Since this is my first time using HXT, I know I’m doing something wrong, but I don’t know how to fix it.

Any help would be great, thanks!

  • 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-16T21:29:21+00:00Added an answer on June 16, 2026 at 9:29 pm

    I ended up finding the answer in a related problem, I didn’t know of the existence of listA (I’m also really new to Arrows), and that fixed it!

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

Sidebar

Related Questions

Today I needed to parse some data out from an xlsx file (Office open
I want to make one project that parse wiki pages and get needed information
friends. I have a 'make'-like style file needed to be parsed. The grammar is
I've loaded an XML file as NSData into memory and parse over the elements
I coded a little Ruby script that would parse a remote XML file and
I am trying to parse an XML file which contains complex arabic letters ..
I need to parse potentially huge XML files, so I guess this rules out
i try to to parse a xml, but i get some errors http://fincha.com/kunden/gordon/ i
I'm working with PHP 5.3 on my local machine and needed to parse a
Needed to write a server text file as the output of a business process

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.