/src/wrappers/xml/examples/xml2_example.e

http://github.com/tybor/Liberty · Specman e · 40 lines · 30 code · 6 blank · 4 comment · 3 complexity · c286ae6690345921029f00824734ea05 MD5 · raw file

  1. class XML2_EXAMPLE
  2. -- Example for wrappers of libxml2 library
  3. insert
  4. XML2_PARSER
  5. ARGUMENTS
  6. create {ANY} make
  7. feature {ANY}
  8. make
  9. -- entry point
  10. do
  11. if argument_count<1 then
  12. print(once "Provide a document%N")
  13. die_with_code(0)
  14. end
  15. doc := parse_file(argument(1))
  16. if doc.root/=Void then parse (doc.root)
  17. else print(once "Got a void root%N")
  18. end
  19. end
  20. doc: XML2_DOC
  21. parse (a_node: XML2_NODE)
  22. -- Recursively parse `a_node'.
  23. local child: XML2_NODE
  24. do
  25. a_node.name.print_on(std_output)
  26. std_output.put_new_line
  27. -- if once " <") until loop end
  28. from child:=a_node.first until child=Void
  29. loop
  30. parse(child)
  31. child:=child.next
  32. end
  33. end
  34. end -- XML2_EXAMPLE