XML file containing multiple root elements

前端 未结 3 1303
青春惊慌失措
青春惊慌失措 2021-01-15 14:13

I have a file which contains multiple sets of root elements. How can I extract the root element one by one?

This is my XML


    

        
3条回答
  •  死守一世寂寞
    2021-01-15 14:30

    You cannot parse your file using an XML parser because your file is not XML. XML cannot have more than one root element.

    You have to treat it as text, repair it to be well-formed, and then you can parse it with an XML parser.

提交回复
热议问题