Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request : Getting attrs ? #2

Open
yellowbean opened this issue Sep 17, 2018 · 2 comments
Open

Feature request : Getting attrs ? #2

yellowbean opened this issue Sep 17, 2018 · 2 comments

Comments

@yellowbean
Copy link

Great work on this library , I think it is the missing pieces I am looking for an intuitive library walking over xml .

I'm wondering that any chance that the library will support getting attributes of a node ?

@tolitius
Copy link
Owner

thanks for the feedback.

xml-in works similar to get-in where it is hunting after the value (i.e. :content in case of XML). the thing with XML is: it is nested. following just the :content allows to dive in to the depth of its structure. carrying attributes along adds complexity, hence I am trying to avoid it.

however it does not prevent you to apply "finishing touches" to the data it returns:

(->> (xml/find-all universe [:universe :system :solar])
                            (filter :attrs))

returns all the elements with attributes:

({:tag :planet,
  :attrs {:age "4.543", :inhabitable "true"},
  :content ("Earth")}
 {:tag :planet,
  :attrs {:age "4.503"},
  :content ("Mars")})

let me know if it helps

@wildwestrom
Copy link

Thank you for this library.

Anyways, I wanted to show a use case for this feature. Here's the gist.
Right now I have a function called elem->maps that grabs out attributes given a key to look it up.

This is pretty jank, so I'd love to see a cleaner way of doing this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants