You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Christian Barth <Ch...@godesys.de> on 2006/11/15 17:24:29 UTC

[Digester] Parsing question

Hello!

I'm completly new to Digester. I want to parse a XML-File to generate a
HTML-Email.

My XML has the following structure:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<email>
	<subject>some subject</subject>
	<from>someone@somewhere.com</from>
	<message>
		<html>
		    <body>
		        <h1>BLABLABLA</h1>
		        <hr></hr>
		        <h2>blabla</h2>
		        <br></br>
		        <h2>bla</h2>
		        <h2>bla</h2>
		        <br></br>
		        <br></br>
		        <br></br>
		        <h2>Greetings,</h2>
		        <h2>bla</h2>
		    </body>
		</html>
	</message>
</email>

My Digester configuration looks as follows:

Digester digester = new Digester(); 
digester.setValidating(false); 
	
digester.addObjectCreate("email", EmailTemplate.class); 
	
digester.addBeanPropertySetter("email/subject", "subject"); 
digester.addBeanPropertySetter("email/message/*", "message");
digester.addBeanPropertySetter("email/from", "from"); 


"subject" and "from" are correctly extracted. But the message part only
return an empty string. Is there a possibility to extract the complete
html-part (surrounded by the "message"-tag) and put it into a String?

Thanks,
Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


RE: [Digester] Parsing question

Posted by David Sills <DS...@datasourceinc.com>.
Been a while since I've used Digester directly (I tend towards using
Betwixt), but I don't see how message is really any different from
subject or from. My first try would be to remove the "/*" from the rule:

digester.addBeanPropertySetter("email/message", "message");

If that doesn't work, try enclosing the HTML in a CDATA section - it
might work better then.

If neither of these work, then my sincerest apologies for any waste of
your time.

David Sills


-----Original Message-----
From: Christian Barth [mailto:Christian.Barth@godesys.de] 
Sent: Wednesday, November 15, 2006 11:24 AM
To: commons-user@jakarta.apache.org
Subject: [Digester] Parsing question

Hello!

I'm completly new to Digester. I want to parse a XML-File to generate a
HTML-Email.

My XML has the following structure:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<email>
	<subject>some subject</subject>
	<from>someone@somewhere.com</from>
	<message>
		<html>
		    <body>
		        <h1>BLABLABLA</h1>
		        <hr></hr>
		        <h2>blabla</h2>
		        <br></br>
		        <h2>bla</h2>
		        <h2>bla</h2>
		        <br></br>
		        <br></br>
		        <br></br>
		        <h2>Greetings,</h2>
		        <h2>bla</h2>
		    </body>
		</html>
	</message>
</email>

My Digester configuration looks as follows:

Digester digester = new Digester(); 
digester.setValidating(false); 
	
digester.addObjectCreate("email", EmailTemplate.class); 
	
digester.addBeanPropertySetter("email/subject", "subject"); 
digester.addBeanPropertySetter("email/message/*", "message");
digester.addBeanPropertySetter("email/from", "from"); 


"subject" and "from" are correctly extracted. But the message part only
return an empty string. Is there a possibility to extract the complete
html-part (surrounded by the "message"-tag) and put it into a String?

Thanks,
Christian

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org