Convert XML to TXT using a script

lmgf81 Posted messages 8 Registration date   Status Member Last intervention   -  
moebius_eye Posted messages 152 Registration date   Status Member Last intervention   -
Hello,

I have a client file in xml format that I would like to convert to txt format.

I also need a specific number of characters for each part.

First 10 characters for the code, 20 for the name, 20 for the address....

Is it possible to create a script that can do this?

Thank you in advance for your help.

Configuration: Windows 7 / Safari 535.19

4 answers

  1. totodunet Posted messages 1513 Status Member 201
     
    To convert it to .txt, just open Notepad and copy the content of your xml into it.
    0
    1. lmgf81 Posted messages 8 Registration date   Status Member Last intervention  
       
      No, because there are the suitcases to remove, put everything on one line while managing the spaces for my character count requirement.
      0
  2. Fallentree Posted messages 2445 Status Member 210
     
    A script::: it's not possible to record anything..
    In PHP, it's really simple...
    0
  3. lmgf81 Posted messages 8 Registration date   Status Member Last intervention  
     
    C'est-à-dire, comment fais-tu ? Je suis nul !!!
    0
    1. Fallentree Posted messages 2445 Status Member 210
       
      $file="Monfichier"; if ($rHandle=@fopen($file, "r")) { $data = file_get_contents($file); fclose($rHandle); } $writeFile="Autrefichier"; if ($wHandle=@fopen($writeFile, "w")) { fwrite($wHandle, $data); fclose($wHandle); } 
      0
    2. lmgf81
       
      client1 adressecl1 CLI01010101010202020202
      client2 adressecl2 CLI01010101010202020202
      0
    3. Fallentree Posted messages 2445 Status Member 210
       
      once $data with the file you search for the data using strstr("<CLTFNOM>");
      working with the indices ....
      otherwise there's a pretty good function
      $tableau=explode($separator,$file); ...
      you recover structure not structure ...
      example $separator="<client> ";
      you have the xml per client you loop afterwards by the separators of the XML structure ...
      In short ...
      0
  4. moebius_eye Posted messages 152 Registration date   Status Member Last intervention   10
     
    What languages do you master? I have a solution in Python with the XML library, in Java, and a more complicated one in PHP.
    But it seems like you didn't look very hard, because you would have come across plenty of libraries capable of doing that in 3 lines of code...
    0