commons-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ivan Rekovic" <ri...@verat.net>
Subject RE: Digester Question
Date Tue, 23 Dec 2003 13:31:10 GMT
The simplest way of grabing ReportSuccesses is to use SetPropertyRule.
See documentation in digester distribution for this.

Basically you will have to create digester, attach rule (with alias
since ReportSuccesses is not valid bean name), add pattern (something
like  IDTDebitInterface/DebitRequests in your case) and parse file with
digester parse method. When parsing is finished you will have property
of your bean setted.

As for your second question. No. Digester can not create XML documents,
but you can look for DOM4J for example witch will suite your needs.

> -----Original Message-----
> From: Juan Alvarado [mailto:jalvarado@duocash.com]
> Sent: Monday, December 22, 2003 11:46 PM
> To: commons-user@jakarta.apache.org
> Subject: Digester Question
> 
> Hello:
> 
> I am relatively new to xml parsing and I just started using the
> commons-digester tools and it seems like it might fit my needs.
> 
> First let me apologize to all you seasoned pros in the field of XML in
> the event that my question seems too simple or if I am just not using
> the right terminology.
> 
> My question is as follows.
> 
> The particular XML that I am working with and in need to parse is
> composed as follows:
> 
> <?xml version="1.0"?>
> <IDTDebitInterface>
> <UserInfo>
> <username>Juan</username>
> <password>Alvarado</password>
> </UserInfo>
> <DebitRequests ReportSuccesses="true">
> <DebitRequest id="1" type="misctrans">
> <account>123</account>
> <amount>10</amount>
> <transtype>vendordebit</transtype>
> <note>Test</note>
> <balancetozero>n</balancetozero>
> </DebitRequest>
> </DebitRequests>
> </IDTDebitInterface>
> 
> As you can see, the node <DebitRequests ReportSuccesses="true">
> contains an attribute ReportSuccesses="true". I need to be able to
grab
> that value so that it can be populated into my corresponding bean.
> Additionally there might be times when there is more than one
attribute
> in a given node and obviously I would need to get those values also.
> Could someone please tell me if this is possible and if so, how to
> accomplish this.
> 
> NEXT QUESTION:
> 
> My application not only has to parse this XML stream, but we also have
> to create this XML from in certain situations. We might for example
> receive a request through the web with the necessary parameters and
> values needed to construct the XML and then pass on to the next layer.
> Can anyone tell me if the digester framework can handle this and if
so,
> I'd appreciate some sample code.
> 
> Thanks in advance.
> 
> 
> ---------------------------------------------------------------------
> 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


Mime
View raw message