This is a read-only archive of lispforum.com. The forum was locked to new users and posts and is preserved here as static HTML from a database snapshot taken on 2019-09-07.

New to Common LISP,Need help in String manipulation function

5 posts · 3362 views

Hi all,
I am a very beginner to CL. I am going through the book in gigamonkeys.com.
(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

Hi, i am going little specific to the requirement.
<?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

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

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/

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

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