parsing - Parser Element with child element -
parsing - Parser Element with child element -
i have illustration document:
<category> <name>nameparent</name> <category> <category> <name>namechild1</name> <category> <name>namechild2</name> </category> </category> </category> </category>
and class:
class category: nsobject { var attributeid:nsstring = "" var namecategory:nsstring = "namenotfound" var objcategory:category? }
how see category recursive class.
the children may have, in turn, other children, , have unlimited number how can handle this? how can construction in parser?
edit: @ time, parser can not find father , children, can not save them in list.
thanks
i implement kind of stack. on each open <category>
force new element on stack , on each </category>
pop lastly 1 stack.
one simple approach utilize array stack.
create class category elements. while parsing, whenever didstartelement
fires elementname == "category"
create new instance of class , farther processing until didendelement
fires, 1 time again elementname == "category"
parsing swift
Comments
Post a Comment