jeudi 4 août 2016

Cant Read xml file using sax Parser with Nokogiri

I am using ruby 1.9.3 with rails 3.1. My requirement is that there is a parser file like below. when i opened with browser; Tags are not aligned in order. After the <item>; the data are clubbed format. There is a presence of

<?xml version="1.0" encoding="utf-8"?>

when I opened in sublime text; it shows after the <item>

<![CDATA[<?xml version="1.0" encoding="utf-8"?>

also after the </item> there is ]]> present. The data needs to be parsed are inside this <item></item>. the method called parse_file form Nokogiri called only start_element, end_element. When we tried manually by editing the file via removing the above statements; then it will call the characters method to fetch the data. Below is the example code. Please provide an automated solution for this.

<batch transactionType="HC"><item><?xml version="1.0" encoding="utf-8"?><C><CI><Ve>00501</Ve></CI></C></item></batch>

image is more useful.enter image description here

Aucun commentaire:

Enregistrer un commentaire