![]() |
|
|
|
#1 |
|
I am unable to preserve white space.
Here is my code: public class xml { public static void main(String[] args) { try{ String jaxpPropertyName = "javax.xml.parsers.SAXParserFactory"; if (System.getProperty(jaxpPropertyName) == null) { String apacheXercesPropertyValue = "org.apache.xerces.jaxp.SAXParserFactoryImpl"; System.setProperty(jaxpPropertyName, apacheXercesPropertyValue); } SAXParserFactory factory = SAXParserFactory.newInstance(); SAXParser parser = factory.newSAXParser(); Reader reader=new StringReader("<?xml version='1.0' encoding='UTF-8'?><References><Reference><Name>RITA MOYER</Name><Address><Street>5001 OAKVIEW DRIVE </Street><City>Los Angeles</City><State>OH</State><ZIP>44089</ZIP></Address><EMail></EMail><Phone>4409678038</Phone><Relationship>MOTHER</Relationship></Reference><Reference><Name>TINA MASLINSKI</Name><Address><Street>4902 MAPLE VIEW DRIVE</Street><City>Los Angeles</City><State>OH</State><ZIP>44089</ZIP></Address><EMail></EMail><Phone>4409675992</Phone><Relationship>FRIEND</Relationship></Reference></References>"); InputSource is=new InputSource(reader); factory.setNamespaceAware(true); parser.parse(is, new PrintHandler()); } catch(Exception e) { e.printStackTrace(); } } } I want the parser to show for Name "Rita Moyer". It now shows "Rita" Thanks for your help soup_or_power@yahoo.com |
|
|
|
|
#2 |
|
Posts: n/a
|
I strongly suspect PrintHandler (which you didn't show us) has the
standard SAX-beginner's problem of forgetting that text may be spread over successive calls to characters(). See any good SAX tutorial for a discussion of how to deal with that. -- () ASCII Ribbon Campaign | Joe Kesselman /\ Stamp out HTML e-mail! | System architexture and kinetic poetry |
|