{{fbdoc item="title" value="libxml2"}}----
De-facto standard library for accessing xml files.

Website: http://xmlsoft.org/
Platforms supported: ""Win32"", Linux
Headers to include: libxml/*.bi
Header version: 2.6.17
Examples: in examples/xml/

{{fbdoc item="ex"}}
{{fbdoc item="filename" value="examples/manual/libraries/libxml.bas"}}%%(freebasic)
#include Once "libxml/xmlreader.bi"
#define NULL 0

Dim As String filename = Command(1)
If( Len( filename ) = 0 ) Then
	Print "Usage: libxml filename"
	End 1
End If

Dim As xmlTextReaderPtr reader = xmlReaderForFile( filename, NULL, 0 )
If (reader = NULL) Then
	Print "Unable to open "; filename
	End 1
End If

Dim As Integer ret = xmlTextReaderRead( reader )
Do While( ret = 1 )
	Dim As const ZString Ptr constname = xmlTextReaderConstName( reader )
	Dim As const ZString Ptr value = xmlTextReaderConstValue( reader )

	Print xmlTextReaderDepth( reader ); _
		xmlTextReaderNodeType( reader ); _
		" "; *constname; _
		xmlTextReaderIsEmptyElement(reader); _
		xmlTextReaderHasValue( reader ); _
		*value

	ret = xmlTextReaderRead( reader )
Loop

xmlFreeTextReader( reader )

If( ret <> 0 ) Then
	Print "failed to parse: "; filename
End If

xmlCleanupParser( )
xmlMemoryDump()
%%

{{fbdoc item="back" value="ExtLibTOC|External Library Table of Contents"}}