-
Notifications
You must be signed in to change notification settings - Fork 98
API for working with XML data isn't very intuitive #73
Comments
Yeah, that's a fair criticism. Still, you figured it out -- so maybe it's not so bad? Or maybe most people give up before you? I guess I secretly loathe XML, and like keeping it in a corner. |
We all do ;) But then there's library systems… Anyways, I won't be offended if you close this as "wontfix", but consider adding a short xml example to the README first. Might help save others some time. |
I'll leave this open until one of those things happen. Thanks @danmichaelo ! |
Seconding that reading xml is not intuitive. Had to look at the test code and this issue before I got it to work. |
Just out of curiosity would people be ok with: for record in MARCReader(open('batch.xml', 'rb')):
# do something useful with a Record creating an in memory array for all the records, and then allowing the iteration to start? I think it would be preferable if it did function as an iterator, but I'm not quite sure how that would combine with the SAX parsing that's going on. I like that MARCReader is an actual iterator, and allows you to process large files. I think this another subconscious reason why I partitioned the XML functionality off to the side. |
Having some xml data,
, I expected from the README example to be able to do something like
but instead I had to do
Determining the file type should be quite easy from reading the first characters of the file stream: xml if "<?xml", json if "{", plain marc otherwise.
Next I wanted to try to serialize a record to XML. The
Record
object has methods likeas_marc()
,as_marc21()
and hm, evenas_json()
, but noas_xml()
! Instead:The text was updated successfully, but these errors were encountered: