New to Common LISP,Need help in String manipulation function

Discussion of Common Lisp
Post Reply
Keerthivasan
Posts: 7
Joined: Wed Dec 28, 2011 7:40 am

New to Common LISP,Need help in String manipulation function

Post by Keerthivasan » Thu Jan 05, 2012 5:00 am

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:

Keerthivasan
Posts: 7
Joined: Wed Dec 28, 2011 7:40 am

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

Post by Keerthivasan » Thu Jan 05, 2012 9:56 am

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 :)

Keerthivasan
Posts: 7
Joined: Wed Dec 28, 2011 7:40 am

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

Post by Keerthivasan » Mon Jan 09, 2012 12:15 am

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 ;)

schoppenhauer
Posts: 99
Joined: Sat Jul 26, 2008 2:30 pm
Location: Germany
Contact:

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

Post by schoppenhauer » Thu Feb 16, 2012 5:30 pm

I think you should use some XML-Library for this (S-XML, etc.) - see cliki.net for a list of XML-Libraries for lisp.
Sorry for my bad english.
Visit my blog http://blog.uxul.de/

wvxvw
Posts: 127
Joined: Sat Mar 26, 2011 6:23 am

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

Post by wvxvw » Fri Feb 17, 2012 2:33 pm

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 :)

Post Reply