newLISP Fan Club

Forum => Anything else we might add? => Topic started by: Dmi on December 16, 2005, 02:07:54 PM

Title: using xml
Post by: Dmi on December 16, 2005, 02:07:54 PM
Does anybody have a nice tricks for converting xml data into a traditional list structure?



xml-parse does the one-to-one conversion of symbolic xml structure to a list.

But I need to extract some particular data from xml into simple nested list structure, that can be easily processed with newlisp. And to skip all other unwanted tags and data.
Title:
Post by: Lutz on December 16, 2005, 02:14:42 PM
There is a function called 'xml-type-tags' used to customize the output. If you put all tags to 'nil' you get streight Lisp expressions with no XML type tags. Or you can modify tags to your needs.



Its all in the manual.



Lutz
Title:
Post by: Lutz on December 16, 2005, 02:24:51 PM
... in case you investigated those possibilities already and it did not help you, perhaps you can give us an example how you want to translate something.



Lutz
Title:
Post by: Dmi on December 17, 2005, 03:06:23 AM
Yes, I know about xml-type-tags :-)

I have a hardly structured data, say the xml output from "xlhtml" convertor.

The structure is about that:
excel_workbook
   sheets
     author
     issuing-date
     other-key-fields
     sheet
       sheet-name
       a-bunch-of-unwanted-keys
       row
        keys-with-style-info
        cell
          keys-with-style-info
          rownum
          colnum
          something...
          cell-data

There also are some other intermediate levels of nesting.



Generally, I want to quick-parse this structure to extract only theese info:
((sheet1-name
  ((cell-data-for-row-1 cell-data-for-row-1....)
   (cell-data-for-row-2 ....)))
 (sheet2-name
  ((cell-data-for-row-2 ...))))

I.e., I want to extract data and nesting only about some keys and skip other info.



I can see a way to imlement some traditional possibilities (say, hook-based parsing), but, possible anyone done it already?