• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

XML : how to parse effectively ?

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ,

Marat
 
author and deputy
Posts: 3150
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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 ]
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
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/
 
Try 100 things. 2 will work out, but you will never know in advance which 2. This tiny ad might be one:
We need your help - Coderanch server fundraiser
https://coderanch.com/wiki/782867/Coderanch-server-fundraiser
reply
    Bookmark Topic Watch Topic
  • New Topic