Convert XML to TXT using a script

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. To convert it to .txt, just open Notepad and copy the content of your xml into it.
    0
    1. No, because there are the suitcases to remove, put everything on one line while managing the spaces for my character count requirement.
      0
  2. A script::: it's not possible to record anything..
    In PHP, it's really simple...
    0
    1. C'est-à-dire, comment fais-tu ? Je suis nul !!!
      0
      1. $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. client1 adressecl1 CLI01010101010202020202
        client2 adressecl2 CLI01010101010202020202
        0
      3. 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
    2. 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