Search code examples
xmllistprologswi-prologpretty-print

In swi-prolog, how to pretty print the Term gotten from load_xml_file('file.xml', Term)?


swi-prolog uses list of list of list of ... to represent XML tree. I tried

write(Term)

it doesn't indent good, and

format(Term)

it doesn't support list, and

pretty_print

it seems it is not for list,and it is defined in rb tree library.


Solution

  • xml_write(+Stream, +Term, +Options)
    

    Usage example:

    ?- load_xml_file('example.xml', Term), xml_write(user, Term, []).