Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Converting .xml files to text..how?

Options
  • 01-06-2007 8:28pm
    #1
    Registered Users Posts: 423 ✭✭


    Not sure if this is the right place to post this..apologies if wrong one!

    Problem: I have .xml files that I need to convert pretty quickly every month into .txt files or files that mean it is a clean read in Word etc.

    Anyone recommend anything? The files are in EditPLus and I've tried to open them directly in Word 2007 but am getting 'Error on linex, column x' etc.

    Thanks a mill for any advice!


Comments

  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    Change the ending from .xml to .txt or do you want to reformat them again?


  • Moderators, Politics Moderators Posts: 39,822 Mod ✭✭✭✭Seth Brundle


    Why would you try and open them in word? :confused:


  • Registered Users Posts: 995 ✭✭✭cousin_borat


    XML Files are machine readable, why would you want to open them in Word!

    Maybe if you explain some more


  • Registered Users Posts: 423 ✭✭loup


    HI there..thanks for the replies. Perhaps I didnt explain well enough. I work for an online gaming site and the game schedules are in .xml format. However I need to extract this information in a 'clean' form to give to our moderators so they have a list of the games and what is on when. When I get them from our programmers in .xml format, I would have to go through and Edit/Replace loads of characters, symbols, etc. I was hoping to be able to re-convert them into a Word format which would strip out all the characters and symbols. Hope this makes sense!!:D


  • Registered Users Posts: 32,136 ✭✭✭✭is_that_so


    Perl has an XML Parser to strip out stuff. Here's a link and there are many of them out there. The sample code shows how it works. You should be able to find some scripts to do it. Search for PERL XML parser examples.

    http://www.oreilly.com/catalog/perlxml/chapter/ch03.html.

    PHP will also let you do it as well.

    http://ie2.php.net/xml

    There are also PHP XML parsers for RSS feeds that you can hack. Some scripts here.

    http://www.hotscripts.com/PHP/Scripts_and_Programs/XML_and_PHP/

    You could also download something like XMLFOX which is freeware .


  • Advertisement
  • Registered Users Posts: 423 ✭✭loup


    Thank you so much! That was exactly what I was looking for..thanks again :)


  • Registered Users Posts: 4,276 ✭✭✭damnyanks


    Also if you are using Word 2007 you can make it readable through word by adding some extra info. The word 2007 document containers are just zip files containing XML files.


  • Registered Users Posts: 423 ✭✭loup


    Ahh thanks damnyanks..I am using Word2007, good to know thanks! :)


  • Registered Users Posts: 5,379 ✭✭✭DublinDilbert


    Why not use XSLT??

    This allows XML documents to be converted into different formats, the most popular of which is HTML.

    You need to generate an XSLT style sheet which describes which bits of the XML to output as HTML.

    There's 2 ways that combining the XML and XSLT can work:-
    1) client side transform, where the browser loads both files and generates a nice HTML page with the data in it.
    2) server side transform, where an application is used to read in both files and output a HTML page.


  • Closed Accounts Posts: 19,777 ✭✭✭✭The Corinthian


    You read an article about XSLT once, didn't you?


  • Advertisement
  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Now, now. Lets all be nice.


  • Registered Users Posts: 614 ✭✭✭dent


    You could ask the programmers to extract the relevant information and place it in a nice HTML page that you can print or the moderators can visit.

    I'm sure they can automate this.

    They will know the best way in your system to do this.


  • Registered Users Posts: 995 ✭✭✭cousin_borat


    The questions been answered well previously by is_that_so and damnyanks. Give it a rest!


  • Registered Users Posts: 5,379 ✭✭✭DublinDilbert


    You read an article about XSLT once, didn't you?


    Sorry was that aimed at me?? I assume it was...


    I know quite a bit about XSLT and the sort of transforms it can perform both binary and text based.

    I thought my overview would be helpful to the OP as a brief overview, which he can look at further. I know it wasn't as technical as renaming the extension of the file from .xml to .txt

    Whats wrong with me suggesting using XSLT, as no one else did?
    Whats wrong with my suggestion?



    Mods if this is the attitude of people in this forum, i will stop posting solutions here and helping people... I have always come here and tried to help people, give them ideas and share some of my experience.


  • Registered Users Posts: 7,468 ✭✭✭Evil Phil


    Thread locked.

    loup if you want to start a new thread feel free to do so. I'll make sure everybody behaves themselves.

    Everybody else, please feel free to use the report post button. That this little fellow you see below everybody's avatar -> report.gif. Reported posts will be taken seriously, in-thread spats won't.


This discussion has been closed.
Advertisement