Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Removing extra digit in xml file

Status
Not open for further replies.

bmonroe

Technical User
Apr 23, 2003
3
BE
I am looking for some help in removing an extra digit for zip code in an xml file. In the record the last number of the zip code needs to be removed. Being a very novice programmer I am hoping someone can help me with this. I need to come up with some sort of script that will read this file and eliminate the extra digit on the zip code. Thanks in advance for your help.

Sample data:

<RECORD_INFO>
<ID>1917000</ID>
<ALT_ID>0000019170000</ALT_ID>
<MAIN_DEST>
<ADDRESS_INFO>
<NAME>john customer</NAME>
<ADDRESS1>P.O BOX 100000</ADDRESS1>
<ADDRESS2>BLDG 123 DET. 11
</ADDRESS2>
<CITY>SAN DIEGO</CITY>
<COUNTY>Duval</COUNTY>
<STATE>CA</STATE>

<POSTAL_CODE>92135-71401</POSTAL_CODE>
<COUNTRY/>
</ADDRESS_INFO>
</MAIN_DEST>
<BILL_PERIOD_FROM>03/19/2003</BILL_PERIOD_FROM>
<BILL_PERIOD_TO>04/18/2003</BILL_PERIOD_TO>
<INVOICE_NO>19175490000</INVOICE_NO>
</RECORD_INFO>
 
if in jscript

var sTempAttribute = Yourmainxml.getAttribute(&quot;POSTAL_CODE&quot;)
sTempAttribute=new String(sTempAttribute)
sTempAttribute=sTempAttribute.substr(0,len(sTempAttribute)-1)

Yourmainxml.setAttribute(&quot;POSTAL_CODE&quot;,sTempAttribute)
 
I am assuming @ Yourmainxml that I am changing this to the xml filename?
 


No, I am getting an error saying that the &quot;application has generated an exception that could not be handled&quot; The script compiles but will not run. Here is what the script looks like now.

------------------------------------------------------------
var Yourmainxml = (&quot;c:\\test.xml&quot;)
var sTempAttribute = Yourmainxml.getAttribut(&quot;POSTAL_CODE&quot;)
sTempAttribute=new String(sTempAttribute)
//changed line is below
sTempAttribute=sTempAttribute.substr(0,(sTempAttribute.length-1))
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top