Ok... For all those boring people out there (like me) who like using Java...
Here is a function that can return to ColdFusion a Java DOM Document object
(HTML or XML) which means you can use the Java object instead of the CF
object...
I haven't tested if it works well or not, all I know is that it returns the
object.
You can either create a new Document by sending an empty string, or create a
document from a piece of XML, by sending that XML as a string to the
function.
Paul
-----code-----
<cfscript>
function createJavaXMLDocumentObject(xmlString) {
// set up the java classes to create a document
java_documentBuilderFactory_class = createObject("java",
"javax.xml.parsers.DocumentBuilderFactory");
java_documentBuilderFactory =
java_documentBuilderFactory_class.newInstance();
java_documentBuilder =
java_documentBuilderFactory.newDocumentBuilder();
// if the string is empty, then return a new document
if(trim(xmlString) eq "") {
return java_documentBuilder.newDocument();
}
// create a string reader
javaStringReader_class = createObject("java",
"java.io.StringReader");
javaStringReader = javaStringReader_class.init(xmlString);
// create the input source
saxInputSource_class = createObject("java",
"org.xml.sax.InputSource");
saxInputSource = saxInputSource_class.init(javaStringReader);
// create a new xml document
return java_documentBuilder.parse(saxInputSource);
}
xmlDocument = createJavaXMLDocumentObject(xmldoc);
xmlDocument2 = createJavaXMLDocumentObject("");
</cfscript>
-----code-----
> -----Original Message-----
> From: Rich Wild [mailto:[EMAIL PROTECTED]
> Sent: 16 July 2003 11:17
> To: '[EMAIL PROTECTED]'
> Subject: RE: [ cf-dev ] adding elements to xml packets
>
>
> > It did come from the docs...
> >
> > It's just REALLY badly documented HOW to do it!
>
> that was the problem. I could find the functions I needed,
> but no background on HOW to use them.
>
> here's the code I ended up with, in case anyone wants a
> simple way of trapping and archiving app errors with <cferror>
>
> <cflock name="errorlock" timeout="5" throwontimeout="Yes"
> type="exclusive">
> <cfif fileexists(expandpath('errors.xml'))>
> <cffile action="READ"
> file="#expandpath('errors.xml')#"
> variable="errorfile">
> <cfelse>
> <cfset errorfile = "">
> </cfif>
> </cflock>
>
> <cfscript>
> if (len(trim(errorfile))) {
> errorpacket = xmlparse(errorfile);
> } else {
> errorpacket = xmlnew();
> errorpacket.xmlRoot = xmlelemnew(errorpacket, "incidents");
> }
> newElemPos = arraylen(errorpacket.incidents.xmlchildren)+1;
> errorpacket.incidents.xmlchildren[newElemPos] =
> xmlElemNew(errorpacket, "error");
> errorpacket.incidents.xmlchildren[newElemPos].xmlchildren[1]
> = xmlElemNew(errorpacket, "date");
> errorpacket.incidents.xmlchildren[newElemPos].xmlchildren[1].x
> mltext = now();
> errorpacket.incidents.xmlchildren[newElemPos].xmlchildren[2]
> = xmlElemNew(errorpacket, "referer");
> errorpacket.incidents.xmlchildren[newElemPos].xmlchildren[2].x
> mltext = xmlformat(error.httpreferer);
> errorpacket.incidents.xmlchildren[newElemPos].xmlchildren[3]
> = xmlElemNew(errorpacket, "diagnostics");
> errorpacket.incidents.xmlchildren[newElemPos].xmlchildren[3].x
> mltext = xmlformat(error.diagnostics); </cfscript>
>
>
> <cflock name="errorlock" timeout="5" throwontimeout="Yes"
> type="exclusive">
> <cffile action="WRITE" file="#expandpath('errors.xml')#"
> output="#tostring(errorpacket)#"
> addnewline="No">
> </cflock>
>
> > -----Original Message-----
> > From: Paul Johnston [mailto:[EMAIL PROTECTED]
> > Sent: 16 July 2003 11:14
> > To: [EMAIL PROTECTED]
> > Subject: RE: [ cf-dev ] adding elements to xml packets
> >
> >
> > It did come from the docs...
> >
> > It's just REALLY badly documented HOW to do it!
> >
> > > heh. how queer!
> > >
> > > Paul's method works well.
> >
> > Now please... Let's at least assume that I can get it right
> sometimes!
> >
> > :D
> >
> > Paul
> >
> >
> >
> > --
> > ** Archive:
> http://www.mail-archive.com/dev%> 40lists.cfdeveloper.co.uk/
> >
>
> > To unsubscribe, e-mail:
> [EMAIL PROTECTED]
> > For additional commands, e-mail:
> [EMAIL PROTECTED] For
> > human help, e-mail: [EMAIL PROTECTED]
> >
>
>
> --
> ** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
>
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail:
> [EMAIL PROTECTED] For human help, e-mail:
> [EMAIL PROTECTED]
>
--
** Archive: http://www.mail-archive.com/dev%40lists.cfdeveloper.co.uk/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
For human help, e-mail: [EMAIL PROTECTED]