This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
Hello Dear Sirs ! I am a newbie in XML world and I need to parse and also write to file yhe next XML Format : <FORMAT NAME="InputQG30Format"> <TransactionCode>QG30</TransactionCode> <FunctionKey>00</FunctionKey> <ProcessType>O</ProcessType> <PreformattingIndicator>no</PreformattingIndicator> <InputFormat> <F VALUE="USER">USERCtx</F> <F VALUE="PSWD">PSWDCtx</F> <F VALUE="NEWPSWD">NEWPSWDCtx</F> <F VALUE="VNPSWD">VNPSWDCtx</F> </InputFormat> </FORMAT> But I have no idea how i can do that ? I will very appretiate your attempt to help me . How i can parse it ? What is the better parser for this case ? Each clue and code snippet will be properly appretiated . Thank you ,
Hi, You can parse it using different methods, 1.Java with Xerces or crimson 2.XALAN with XSLT 3.ASP with MSXML 4. ...... 1.If you want to write a java code to parse the input XML you can read this tutorial and try using DOM orUSing SAX These two tutorials will give you some basics ideas on how to parse the xml. You can download either Xerces or Crimson as Parser, I found Crimson is faster. 2.you can write XSLT to convert the inputXML in to any format you want.You have to learn XSLT which is relatively easy.(don't have good tutorial links now,will give you on monday). But the XML tutorials at this link http://www.w3schools.com/ and the XML Processing tutorials will sure help you,the former will teach you the fundas of XML. 3.OR download MSXML from MS site ,after installing double click MSXML help from your desktop,you will get bunch of tutorials to parse xml using asp,vb,js,vbscript etc., [ December 22, 2002: Message edited by: Balaji Loganathan ]
Not everybody here is a sir that can help you out. FormatName fn = (FormatName)u.unmarshal(xmlFile); FormatName tempfn = ObjectFactory.createFormatName(); TransactionCode tc = ObjectFactory.createTransactionCode(); tc.setValue("QG30"); etc. .... Marshaller m = jc.createMarshaller(); m.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, Boolean.TRUE ); m.marshal(tempfn, xmlOutFile); If you're interested in using java objects created from the xml, and are more comfortable with Java, using JAXB might help you. http://java.sun.com/xml/jaxb/