Flex through Request , the foreground is packaged into Xml To the background, now roughly speaking, in the background javax is how to resolve String form of Xml , convert it to Bean , the following method is the way I save Personal address information when I do contact management, and the red flag is to get the value of the corresponding node attribute in a node.
Public void saveaddr (String address) {
System.out.println ("In CMD, save address Information");
Documentbuilderfactory factory = Documentbuilderfactory.newinstance ();
Documentbuilder Builder;
Try {
Builder = Factory.newdocumentbuilder ();
StringReader sr = New StringReader (address);
InputSource is = new inputsource (SR);
Document doc = Builder.parse (IS);
list<contactaddr> list = new arraylist<contactaddr> ();
NodeList nodelist=doc.getelementsbytagname ("address");
for (int i=0;i<nodelist.getlength (); i++) {
Contactaddr contactaddr=New contactaddr ();
if ("Mailbox". Equals
(Nodelist.item (i). GetAttributes (). getNamedItem ("mode"). Getnodevalue ())
{
Contactaddr.setdeliverymode ("1");
}Else{
Contactaddr.setdeliverymode ("0");
}
Contactaddr.setdeliveryaddr
(Nodelist.item (i). GetAttributes (). getNamedItem ("addr"). Getnodevalue ());
List.add (CONTACTADDR);
}
SERVICE.UPDATECONTACTADDR (list);
Catch(Parserconfigurationexception e) {
E.printstacktrace ();
Catch (Saxexception e) {
E.printstacktrace ();
Catch(IOException e) {
E.printstacktrace ();
}
}