0

hi how to use the valid part of an xml present inside a broken xml

Ex: <nodea>
<nodeb>DATA</nodeb
<nodec> DATA </nodec>

at above since the nodea is not getting closed so this is a broken xml,but the nodeb & nodec are the valid Xmls present inside nodea. so can i retrive the data inside them or not using libxml2.

Subrat nayak.
  • 405
  • 1
  • 7
  • 25

1 Answers1

0

You have to fix the file by a heuristical hack before you parse it.

$ cat broken.xml 
<nodea>
<nodeb>DATA</nodeb 
<nodec> DATA </nodec>
$ < broken.xml sed 's%</nodeb[^>]%</nodeb>%'
<nodea>
<nodeb>DATA</nodeb>
<nodec> DATA </nodec>
ceving
  • 21,900
  • 13
  • 104
  • 178