Menu ▾ ▴

[newbie] simple TXT content into a clean XML

dorgeville
2009-08-06
2012-11-13
  • dorgeville

    dorgeville - 2009-08-06

    Hello there, I'm a newbie but I'd be really happy if I could turn this simple HTML file into a clear XML file. Because I have something like 300 pages, I want to automate them with InDesign instead of manually doing the work.
    I believe there's a way but I can find it easier if you can enlighten me about it.

    So here's the deal, in the text file, the content is exactly like this;

    Parabolia, 2008, some text here, 40 x 56 cm., Another content /*br
    goes here.

    Every comma refers to another content except "some text here, 40 x 56 cm.". So it would basically be like this if I'd manually turn it into an XML;

    <title>Parabolia</title>
    <year>2008</year>
    <textandsize>some text here, 40 x 56 cm.</textandsize>
    <collection>Another content goes here.</collection>

    Sorry if this one is a silly question but I hope you got the point, and I'd be glad if you help me.
    Thank you (:

     
    • François-R Boyer

      I don't think this is the right forum for this, but anyway…  Since it is a Notepad++ (not an InDesign) forum, here is how to do something like that in Notepad++.

      First remove extra line-brakes so each entry is on one line: do a Replace all, in "Extended" mode, to replace "<br>\r\n" (if your file has Windows format end of lines) by nothing.
      Then change your coma separated lines in XML:  do a Replace all, in "Regular expression" mode, to replace " ([^,]*),([^,]*),([^,]*),([^,]*),(.*)" by "<title>\1</title>\n<year>\2</year>\n<textandsize>\3,\4</textandsize>\n<collection>\5</collection>"

      If you are a newbie, I'll explain a bit the last replace.  "[^,]" means any character except a coma, and the "*" means as many occurrences as possible.  The text found by each part in parenthesis is later referenced by \1 \2 etc.  And "." means any character (not end of lines).