• Post Reply Bookmark Topic Watch Topic
  • New Topic

Replacing a string in line 2 based on a string value in line 1  RSS feed

 
Pradeep Bommisetty
Greenhorn
Posts: 2
Java Tomcat Server Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to replace a string on line 2 based on a string value in line 1, is there any way to do that easily ?
Below is the sample file. If TOKEN value is -1, change the value in SYNCLOST to Y if not, ignore.
<REQUEST1>
<PAYEESYNCRS>
<TOKEN>-1</TOKEN>
<SYNCLOST>N</SYNCLOST>
</PAYEESYNCRS>
<PMTSYNCRS>
<TOKEN>0</TOKEN>
<SYNCLOST>N</SYNCLOST>
<BANKACCTFROM>
<BANKID>243374218</BANKID>
<ACCTID>1006000382</ACCTID>
<ACCTTYPE>CHECKING</ACCTTYPE></BANKACCTFROM></PMTSYNCRS>
<RECPMTSYNCRS>
<TOKEN>-1</TOKEN>
<SYNCLOST>N</SYNCLOST>
 
Paul Clapham
Sheriff
Posts: 22829
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If this is an XML document (which it looks like it is) then I would use Java's built-in XML tools to make the changes.
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's an Open Financial Exchange (OFX) document, which is XML.
I'm with Paul, you should use an XML parsing approach using JAXP or JAXB to modify the content.
If you need it, you can download the XSD here.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!