Re: parsing xml with zip, xml and clojure.data.zip
This may help: http://clojure-doc.org/articles/tutorials/parsing_xml_with_zippers.html On Wed, Jun 5, 2013 at 9:54 AM, Ryan Moore niclas1...@gmail.com wrote: Hi, I've read http://nakkaya.com/2009/12/07/zipping-xml-with-clojure/ and http://stackoverflow.com/questions/1194044/clojure-xml-parsing/9595315#comment24442712_9595315 , but the usage of (xml-) is still mysterious to me. If I have this for my xml file... (def myxml (zip-str level1 level2 a='the attribute' level3aText in level 3a/level3a level3bText in level 3b./level3b /level2 /level1)) My question is how the xml- function determines how nested you have to specify things. Eg (xml- myxml :level1 text) = () (xml- myxml :level2 text) = (Text in level 3aText in level 3b.) (xml- myxml :level2 :level3a text) = (Text in level 3a) The last call gives the text in 3a, but why don't you have to specifiy that it is under level 1 as well as level 2? Thanks -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out. -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: parsing xml with zip, xml and clojure.data.zip
AFAIK your var myxml already refers to the root node of your XML document. So your first example searches for a tag called level1 inside the root tag (which is level1). Obviously, there is no such node and the text is empty. Your second example extracts a textual representation of the child nodes (plural) of tag level2. The third example references the tag level3a inside the tag level2 and extracts the text, which contains no more child nodes but just the text. Hope that helps Stefan -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.
Re: parsing xml with zip, xml and clojure.data.zip
Ahh, so if the var refers to the root that would explain why specifying the root never returns anything. Thanks. On Wednesday, June 5, 2013 11:54:49 AM UTC-4, Stefan Kamphausen wrote: AFAIK your var myxml already refers to the root node of your XML document. So your first example searches for a tag called level1 inside the root tag (which is level1). Obviously, there is no such node and the text is empty. Your second example extracts a textual representation of the child nodes (plural) of tag level2. The third example references the tag level3a inside the tag level2 and extracts the text, which contains no more child nodes but just the text. Hope that helps Stefan -- -- You received this message because you are subscribed to the Google Groups Clojure group. To post to this group, send email to clojure@googlegroups.com Note that posts from new members are moderated - please be patient with your first post. To unsubscribe from this group, send email to clojure+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/clojure?hl=en --- You received this message because you are subscribed to the Google Groups Clojure group. To unsubscribe from this group and stop receiving emails from it, send an email to clojure+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/groups/opt_out.