XML Server Getting Started
private String getContextName(String spName, String functionName)
{
String result=spName;
return result;
}
public String getXML() throws java.io.IOException {
String result = null;
StringWriter sw = null;
try {
sw = new StringWriter();
getNodeXML(_doc, sw);
result = sw.getBuffer().toString();
} finally {
sw.close();
}
return result;
}
/** Prints the specified node, recursively. */
public void getNodeXML(Node node, StringWriter sw) {
// is there anything to do?
if ( node == null ) {
return;
}
int type = node.getNodeType();
switch ( type ) {
// print document
case Node.DOCUMENT_NODE: {
// sw.write("");
getNodeXML( ((Document)node).getDocumentElement(), sw);
sw.flush();
break;
}
// print element with attributes
case Node.ELEMENT_NODE: {
sw.write( < );
sw.write(node.getNodeName());
NamedNodeMap attrs = node.getAttributes();
if (attrs!=null) {
int i;
for ( i = 0; i < attrs.getLength(); i++) {
2000 2002 Computer Technology Inc. All rights reserved.
Page 61
J2EE Web Hosting Tundra XML Server Pages J2EE Hosting
|
|
|
|
TotalRoute.net Business web hosting division of Vision Web Hosting Inc. All rights reserved. |