Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Edit a file
Message
From
05/08/2009 11:13:33
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Title:
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01416197
Message ID:
01416202
Views:
66
>I have an xml file that I need to edit programatically to remove some text. This file is our payroll file and seems to convert to a cursor if I remove some tags. Here is a sample of the information:
>
>
><?xml version="1.0" encoding="utf-8" ?> 
>- <Report p1:schemaLocation="PayRegExtract http://99.99.9.999/ReportServer?%2fTotalCompensation%2fPayRegExtract&rs%
>3aCommand=Render&rs%3aFormat=XML&rs%3aSessionID=eo4karztrbozd545bjfj0orz&rc%3aSchema=True" 
>Name="PayRegExtract" xmlns:p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="PayRegExtract">
>- <table1>
>- <Detail_Collection>
>       <Detail PP ......
>       <Detail PP ......
>       <Detail PP ......
>   </Detail_Collection>
>  </table1>
></Report>
>
>
>the information I am trying to remove is:
>
>
>- <Report p1:schemaLocation="PayRegExtract http://99.99.9.999/ReportServer?%2fTotalCompensation%2fPayRegExtract&rs%
>3aCommand=Render&rs%3aFormat=XML&rs%3aSessionID=eo4karztrbozd545bjfj0orz&rc%3aSchema=True" 
>Name="PayRegExtract" xmlns:p1="http://www.w3.org/2001/XMLSchema-instance" xmlns="PayRegExtract">
>
>
>and the end tag
>
>
></Report>
>
>
>is there anyway to edit this xml file programatically or even cycle through each line and rewrite it to another file picking up the lines I need?
>
>
>thanks
>Nick

If the file is too big to put in a string you could always use low level file functions

This assumes the report tag is all on one line and not bigger then 500 chars.
ln_xml = FOPEN('xmlfile.xml')
ln_newxml = FCREATE('newxml.xml')

DO WHILE .NOT. FEOF(ln_xml)
   lc_string = FGETS(ln_xml, 500)
  IF UPPER(LEFT(LTRIM(lc_string), 8)) = "<REPORT "
    lc_string = "<Report>"
  ENDIF
  =FPUTS(ln_newxml, lc_string)
ENDDO
=FCLOSE(ln_xml)
=FCLOSE(ln_newxml)
Charles

"The code knows no master." - Chuck Mautz
"Everybody is ignorant, only on different subjects." - Will Rogers
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform