Solved

Which XML parser should I used for my requirement

Posted on 2016-08-18
11
76 Views
Last Modified: 2016-08-22
I have a requirement

1) To decrypt the PGP encrypted XML file in memory,
2) and search for all the occurrences of  'card_number' element
3) encrypt them using other encryption API and replace the clear text value of 'card_number' element value
4) There after encrypt the whole XML file
5) and finally store that xml file on disk

During each execution of my Java program, I may have about 1 to 4 XML files to be processed for above requirement. Each file can have about 600 to 1000 'card_number' elements. Each decrypted file (if stored on disk can be  100 to 200 KB). But I will not have to let store on disk, keep in memory and process.

I have been looking into couple options:

1)  JDOM parser
2) DOM4J
3) or don't use any external jars/libraries but use core JDK API  like
https://docs.oracle.com/javase/8/docs/api/index.html?javax/xml/parsers/DocumentBuilder.html

I have been reading different options at http://www.tutorialspoint.com/java_xml/java_dom4j_parser.htm, and not able to decide which parser is suitable for my requirement.
0
Comment
Question by:MehtaJasmin
  • 4
  • 4
  • 3
11 Comments
 
LVL 16

Expert Comment

by:gurpsbassi
ID: 41761511
Either of 1,2,3 would work.
0
 

Author Comment

by:MehtaJasmin
ID: 41761549
I know either of them work, the reason I explained in great detail what my requirement is to select the best suitable out of 3.

So I am looking for that answer.
0
 
LVL 16

Expert Comment

by:gurpsbassi
ID: 41761978
U want 'the best'?

Why don't you go on the wiki page for each of those projects and see some examples of how to use each one and judge it from there?
0
The New “Normal” in Modern Enterprise Operations

DevOps for the modern enterprise offers many benefits — increased agility, productivity, and more, but digital transformation isn’t easy, especially if you’re not addressing the right issues. Register for the webinar to dive into the “new normal” for enterprise modern ops.

 
LVL 86

Expert Comment

by:CEHJ
ID: 41762216
Security best practice would actually dictate that the most sensitive tokens be hashed (one-way encryption), where possible, such that nobody could know their plaintext values.
0
 

Author Comment

by:MehtaJasmin
ID: 41762409
CEHJ,

Can you please reply in context of XML parser?  I am good with my all encryption/decryption process. My focus is to select the best suitable XML parser for my need.

Thanks
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41762456
XMLReader in the JDK would be fine
0
 

Author Comment

by:MehtaJasmin
ID: 41762667
Thanks for suggesting XMLReader. I am having hard time to search for any simple example of XMLReader usage to edit the xml element. Any good example showing, step by step how to manipulate the xml file using this API would be appreciated.
0
 
LVL 86

Accepted Solution

by:
CEHJ earned 500 total points
ID: 41762722
Actually, on second thoughts, if memory is not a problem, it might be easier with a DOM approach. JDOM would allow you to select the elements you need to change
0
 
LVL 16

Expert Comment

by:gurpsbassi
ID: 41763154
how about doing what a software developer would do, try some quick examples with the three technologies mentioned. Pick one you prefer working with.
0
 

Author Closing Comment

by:MehtaJasmin
ID: 41765192
I used DOM Parser API (inbuilt in JDK) and it worked great. Thanks a lot.
0
 
LVL 86

Expert Comment

by:CEHJ
ID: 41765762
:)
0

Featured Post

Webinar: Aligning, Automating, Winning

Join Dan Russo, Senior Manager of Operations Intelligence, for an in-depth discussion on how Dealertrack, leading provider of integrated digital solutions for the automotive industry, transformed their DevOps processes to increase collaboration and move with greater velocity.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
ejb on wildfly 5 30
java example issue 5 25
Selenium docs api java index 3 48
How to implement an additional command 16 40
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Viewers learn about the “while” loop and how to utilize it correctly in Java. Additionally, viewers begin exploring how to include conditional statements within a while loop and avoid an endless loop. Define While Loop: Basic Example: Explanatio…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…

832 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question