Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Edit a file
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Versions des environnements
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Divers
Thread ID:
01416197
Message ID:
01416222
Vues:
76
>>>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
>>
>>It depends how big is that file:
>>
>>lnLines = ALINES(laXML, FILETOSTR("your file with full path to it.XML")
>>FOR lnFor = 1 TO lnLines
>>    ? laXML[lnFor]
>>NEXT
>>
>>But why you need to remove something in it?
>>Could you use XMLAdapter to get the file?
>
>I tried the following code:
>
>
>LOCAL oxml as XMLAdapter
>oxml = NEWOBJECT("xmladapter")
>oxml.LoadXML("C:\test2\PayRegExtract.xml")
>
>
>and it gave me following error:
>
>
>XML Error: XML Parse error: Invalid at top level of the document.
>Line 1, Position 1 C:\test\PayRegExtract.xml
>
>
>Then I tried
>
>
>SELECT * from xfer_payroll INTO CURSOR crsparse readwrite
>SELECT crsparse
>XMLTOCURSOR("C:\test2\PayRegExtract.xml","crsparse",512)
>browse
>
>
>and the cursor shows Detail_Collection column only
>
>next I tried West Wind Client Tools and remove the all the tags except for table1
>
><?xml version="1.0"?>
><table1>
>	<Detail_Collection>
>		<Detail PP="
>...
>...
>	</Detail_Collection>
></table1>
>
>
>and that works like a charm. So I was think of removing the offending tags programatically and running the xml through West Wind XML tools. I'm not very savy with XML, how would I correct the XMLAdapter issue (how is it that used, couldn't understand examples) or XMLTOCURSOR issue? The file is 1.5mb.


Check RespectNesting property in XMLAdapter.
Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
The only thing normal about database guys is their tables.
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform