Hi,
I'm a new user on newLISP and I would like to know how to save the result of an xml-parse on an xml file to an lsp file.
Best Regards.
saving the buffer
Re: saving the buffer
That's fairly easy to do in newLISP: http://www.newlisp.org/downloads/newlis ... .html#save. Happy hacking!
(λx. x x) (λx. x x)
-
- Posts: 3
- Joined: Fri May 17, 2013 11:24 pm
Re: saving the buffer
hi,
thanks rickyboy for your answer, i already tried the function save :
(save "output.lsp" xml-parse (read-file "input.xml"))
am i doing it wrong ?
thanks rickyboy for your answer, i already tried the function save :
(save "output.lsp" xml-parse (read-file "input.xml"))
am i doing it wrong ?
Re: saving the buffer
Yes. :) No worries though. The most important thing to rememeber about using save is that whatever you require to be saved must be referenced by a symbol. So, all you need to do before calling save is to get the output of xml-parse referenced by a symbol. Use something like define or any variation of set (for instance, setq, setf) — and there are other primitives that assign values to symbols — to accomplish this. Here's an example.
Now go look at the contents of stuff.lsp. You should see a set expression with the symbol you used (in this example, the symbol is stuff) and its value at the time you performed the save.
And as Lutz noted in the manual entry for save, you can later perform a load to retrieve what you saved. Here's what it looks like from a clean (i.e. new invocation of the) REPL.
Pretty cool, eh?
Code: Select all
$ newlisp
newLISP v.10.4.5 on OSX IPv4/6 UTF-8 libffi, execute 'newlisp -h' for more info.
> (setf stuff (xml-parse "<stuff><a>42</a><b>hello</b><c>more</c></stuff>"))
(("ELEMENT" "stuff" () (("ELEMENT" "a" () (("TEXT" "42"))) ("ELEMENT" "b" () (("TEXT"
"hello")))
("ELEMENT" "c" () (("TEXT" "more"))))))
> (save "stuff.lsp" 'stuff)
true
And as Lutz noted in the manual entry for save, you can later perform a load to retrieve what you saved. Here's what it looks like from a clean (i.e. new invocation of the) REPL.
Code: Select all
$ newlisp
newLISP v.10.4.5 on OSX IPv4/6 UTF-8 libffi, execute 'newlisp -h' for more info.
> (load "stuff.lsp")
(("ELEMENT" "stuff" () (("ELEMENT" "a" () (("TEXT" "42"))) ("ELEMENT" "b" () (("TEXT"
"hello")))
("ELEMENT" "c" () (("TEXT" "more"))))))
> ;;
> ;; It's really loaded and referenced by the symbol `stuff'. Check it out:
> ;;
> stuff
(("ELEMENT" "stuff" () (("ELEMENT" "a" () (("TEXT" "42"))) ("ELEMENT" "b" () (("TEXT"
"hello")))
("ELEMENT" "c" () (("TEXT" "more"))))))
(λx. x x) (λx. x x)
-
- Posts: 3
- Joined: Fri May 17, 2013 11:24 pm
Re: saving the buffer
perfect , i corrected the syntaxe and it is working now.
Thanks so much, have a nice day,
Code: Select all
> (setf mysymbol (xml-parse (read-file "ex.xml")))
> (save "example.lsp" 'mysymbol)
true