0

I have several XML files of the following format in path location:

enter image description here

<Group>
  <Group_No>1</Group_No>
  <Group_Name>One</Group_Name>
  <Member_List>
    <Member>
      <Member_No>1</Member_No>
      <Member_Name>Mike</Member_Name>
    </Member>
    <Member>
      <Member_No>2</Member_No>
      <Member_Name>Jacob</Member_Name>
    </Member>
  </Member_List>
</Group>

I want to read all those XML files and create Group and Member data objects and save them to a MySQL DB using Haskell(I know I need to use HXT and HDBC libraries but I am confused as to how I could use them). Though there are examples for reading XML, they do not show how to traverse through the objects to save to DB.

DB structure:

DB name : L group_member_db

Group table:

Group ID:PK , Int, AutoIncrement

Group No: String

Group Name:String

Member Table:

Member ID:PK, Int, AutoIncrement

Member No:String

Member Name:String

Thanks in advance

Jacob
  • 77,566
  • 24
  • 149
  • 228
harshainfo
  • 504
  • 7
  • 11
  • 1
    Currently your question is too broad. Can you break it down to an individual problem you're having? There are several Haskell libraries for reading XML files. Have you created your own data types `Group` and `Member`? What do they look like? Break down your problem into smaller pieces: 1) how do I read files? 2) How do I turn the XML into some record? 3) How do I save a record to my database? – jkeuhlen May 09 '18 at 17:12
  • Thanks for your comment and breaking my problem into smaller pieces. But I do not want to post them as three separate questions because I am unable to combine different solutions. However I have datatypes as : data Group = Group {GroupNo, GroupName :: String} and data Member = Member {MemberNo, MemberName :: String} – harshainfo May 09 '18 at 17:37
  • Hey @harshainfo, it would be easier to help you if we had the actual XML file, not an image of it. Could you post that? – MCH May 12 '18 at 10:41
  • XML file added as a code block for easy copying. – harshainfo Jun 04 '18 at 18:06

0 Answers0