JuliaIO / EzXML.jl

XML/HTML handling tools for primates

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Question: How to handle attributes?

EricForgy opened this issue Β· comments

Hi πŸ‘‹

Very cool package 😍

I'm struggling a little bit with eachattribute. I was trying to construct a Dict from node attributes, but I am doing something wrong. I tried:

element = parsexml("""<Test attr1="1" attr2="2"/>""").root

d = Dict{String,Any}()
for attr in eachattribute(element)
    d[attr.name] = attr.value
end
ERROR: type Node has no field value

What is the correct way to do this?

Thank you πŸ™

Got it 😊

Instead of attr.value, it should be attr.content πŸ‘