aspose file tools*
The moose likes XML and Related Technologies and the fly likes Parsing an XML for given input Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Engineering » XML and Related Technologies
Bookmark "Parsing an XML for given input " Watch "Parsing an XML for given input " New topic
Author

Parsing an XML for given input

Rakesh Bagaria
Greenhorn

Joined: Sep 06, 2009
Posts: 14
<PROJECT_NAME NAME="POSTPAID_GLB">
<DB_PROFILE PROFILE="UAT19">
<DB_CONNECT_CODE CONNECT_CODE="USAGE1">
<DB_HOST>indlin537</DB_HOST>
<DB_INSTANCE>GLBABP2</DB_INSTANCE>
<DB_PORT>1521</DB_PORT>
<DB_USER>GLBDB19</DB_USER>
<DB_PASSWORD>GLBDB19</DB_PASSWORD>
</DB_CONNECT_CODE>[size=9] [/size]
<DB_CONNECT_CODE CONNECT_CODE="USAGE2">
<DB_HOST>indlin537</DB_HOST>
<DB_INSTANCE>GLBABP2</DB_INSTANCE>
<DB_PORT>1521</DB_PORT>
<DB_USER>GLBDB19</DB_USER>
<DB_PASSWORD>GLBDB19</DB_PASSWORD>
</DB_CONNECT_CODE>
<DB_CONNECT_CODE CONNECT_CODE="USAGE3">
<DB_HOST>indlin537</DB_HOST>
<DB_INSTANCE>GLBABP2</DB_INSTANCE>
<DB_PORT>1521</DB_PORT>
<DB_USER>GLBDB19</DB_USER>
<DB_PASSWORD>GLBDB19</DB_PASSWORD>
</DB_CONNECT_CODE>
</DB_PROFILE>
<DB_PROFILE PROFILE="UAT17">
<DB_CONNECT_CODE CONNECT_CODE="USAGE1">
<DB_HOST>indlin007</DB_HOST>
<DB_INSTANCE>GLBABP7</DB_INSTANCE>
<DB_PORT>1528</DB_PORT>
<DB_USER>DB17</DB_USER>
<DB_PASSWORD>DB17</DB_PASSWORD>
</DB_CONNECT_CODE>
</DB_PROFILE>
</PROJECT_NAME>


I want to write a parser like i will have PROFILE name and CONNECT_CODE as input and function should parse corresponding tags .
like for profile "UAT19" and CONNECT_CODE "USAGE1"

below should get parser
<DB_PROFILE PROFILE="UAT19">
<DB_CONNECT_CODE CONNECT_CODE="USAGE1">
<DB_HOST>indlin537</DB_HOST>
<DB_INSTANCE>GLBABP2</DB_INSTANCE>
<DB_PORT>1521</DB_PORT>
<DB_USER>GLBDB19</DB_USER>
<DB_PASSWORD>GLBDB19</DB_PASSWORD>
</DB_CONNECT_CODE>

like for USAGE2

DB_CONNECT_CODE CONNECT_CODE="USAGE2">
<DB_HOST>indlin537</DB_HOST>
<DB_INSTANCE>GLBABP2</DB_INSTANCE>
<DB_PORT>1521</DB_PORT>
<DB_USER>GLBDB19</DB_USER>
<DB_PASSWORD>GLBDB19</DB_PASSWORD>
</DB_CONNECT_CODE>


please help i know little bit about SAX parser.



Ulf Dittmer
Marshal

Joined: Mar 22, 2005
Posts: 42931
    
  68
If I search for "sax tutorial", I get a whole lot of results, starting with a chapter from Oracle's Java Tutorial (which should always be your first stop for learning Java). Have you worked through any of those?
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 40052
    
  28
Not a “beginning” question. Moving.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Parsing an XML for given input