PageRenderTime 4ms CodeModel.GetById 2ms app.highlight 0ms RepoModel.GetById 1ms app.codeStats 0ms

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