-
Notifications
You must be signed in to change notification settings - Fork 0
Open
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers
Description
how to make the following work
require "xmlt"
XML_FRAGMET = <<-XML
<repository version="1.2">
<version>2</version>
<element>
<name>test</name>
</element>
<element>
<name>test2</name>
</element>
</repository>
XML
class Element
include XMLT::Serializable
property name : String
end
class Repository
include XMLT::Serializable
property version : String
@[XMLT::Field(new_root: "element")]
property elements : Array(Element)
end
module Txmltest
repo = Repository.from_xml XML_FRAGMET, root: "repository"
p! repo.version
if elements = repo.elements
elements.each do |elm|
p! elm
end
end
endI get the following error
~/P/C/txmltest (main) [1]> shards run
Dependencies are satisfied
Building: txmltest
Error target txmltest failed to compile:
Showing last frame. Use --error-trace for full trace.
In lib/xmlt/src/objects.cr:18:5
18 | new node, root: root
^--
Error: no overload matches 'Array(Element).new' with types XML::Node, root: String
Overloads are:
- Array(T).new(size : Int, value : T)
- Array(T).new(initial_capacity : Int)
- Array(T).new()
- Array(T).new(size : Int, & : (Int32 -> T))
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't workinggood first issueGood for newcomersGood for newcomers