Re: Newbie merlin/http question (find out about SOAP)
"Samuel Ferrer" <[email protected]> Sun, 17 Oct 2004 14:51:17 +0000
| Newsgroups | gmane.comp.jakarta.avalon.user |
|---|---|
| Message-ID | <[email protected]> |
Is not a soap message. But it is very easy to use the SAXP api to parse the
xml messages and retrieve data. Here is one example.
Observe that the constructir only accept path, but you can add a new one
accepting a StringReader as argument.
then use: builder.parse(new InputSource(your string reader)).
if you have more questions just ask.
Example-----------------------------------------------------------------------------------------------------------------
package ferra.xml;
//packages for parser
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import org.w3c.dom.Document;
//package for node lookup ... using XPath
import org.apache.xpath.XPathAPI;
import java.io.*;
public class XMLObject {
private Document doc = null;
public XMLObject(String path){
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance();
try{
DocumentBuilder builder = factory.newDocumentBuilder();
doc = builder.parse(new File(path));
}
catch(Exception e){
}
}
public XMLObject(Document doc){
this.doc = doc;
}
public String getValue(String path){
try{
return
XPathAPI.selectSingleNode(doc.getDocumentElement(),path).getNodeValue();
}
catch(Exception e){
return null;
}
}
}
--------------------------------------------------------
//Maquina
_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.com/