Page 1 of 1

New to Common LISP,Need help in String manipulation function

Posted: Thu Jan 05, 2012 5:00 am
by Keerthivasan
Hi all,
I am a very beginner to CL. I am going through the book in gigamonkeys.com.

Code: Select all

(setq data (car data))
	  (setq lsr-xml (gethash 'cl-user::LSR_XML data)) ;; seem to have to refer to cl-user to make this work right
	  (setq xml-as-list (get-list-from-xml lsr-xml t))
In the above code , i get a soap request and set to lsr-xml variable. i need to unwrap the content from the soap request. Please help me. I appreciate all your help. Thanks for your time and help. :roll:

Re: New to Common LISP,Need help in String manipulation function

Posted: Thu Jan 05, 2012 9:56 am
by Keerthivasan
Hi, i am going little specific to the requirement.

Code: Select all

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>

</soap:Envelope>
Now, i need to get the content inside <soap:Body> tags. I have tried to use "remove" and "replace-all" function. but, i am not able to make it work. :( Thanks again for your time :)

Re: New to Common LISP,Need help in String manipulation function

Posted: Mon Jan 09, 2012 12:15 am
by Keerthivasan
Hi all, Since i was not able to do it in LISP. I just made this in java, after LISP handles the output to my java code. Thanks ;)

Re: New to Common LISP,Need help in String manipulation function

Posted: Thu Feb 16, 2012 5:30 pm
by schoppenhauer
I think you should use some XML-Library for this (S-XML, etc.) - see cliki.net for a list of XML-Libraries for lisp.

Re: New to Common LISP,Need help in String manipulation function

Posted: Fri Feb 17, 2012 2:33 pm
by wvxvw
I used this library http://common-lisp.net/project/cxml/ some time ago. I must say that the documentation on it may be confusing at the beginning... but worked all good in the end. It seriously lacks the listing of all available functions, methods and their specializations, instead it says that it "implements all DOM methods" and you are left to figure out what are those methods, but with some help from apropos, you'd get the basic idea of the insides.

PS:

Code: Select all

(require 'cxml)

(defparameter
 *xml*
 (cxml:parse "<?xml version=\"1.0\"?>
<soap:Envelope
xmlns:soap=\"http://www.w3.org/2001/12/soap-envelope\"
soap:encodingStyle=\"http://www.w3.org/2001/12/soap-encoding\">

<soap:Body xmlns:m=\"http://www.example.org/stock\">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>

</soap:Envelope>"
(cxml-dom:make-dom-builder)))

(dom:child-nodes
 (aref (dom:get-elements-by-tag-name *xml* "soap:Body") 0))
This would basically do, precisely what you have asked. But then, XML in itself is quite a convoluted format, when combined with SOAP it makes it... well, I don't really want to continue :) but I hope you liked the Java thing you wrote :)