Dear Monks

I have already asked same type of the doubt earlier. I have asked for converting the text splitted with tab space to elements.

Now im facing 2 problems. Even though i some what managed the first one, im unable to solve the second.

First one is:

Im having the input file separated by tabspaces

Input: <thead> abc bcd def abc bcd def abc bcd def </thead> OUTPUT: <thead> <row><col>abc</col><col>bcd</col><col>def</col></row> <row><col>abc</col><col>bcd</col><col>def</col></row> <row><col>abc</col><col>bcd</col><col>def</col></row> </thead>

I have done it by using subs_text(qr{(.+?)\n}m,"row") and then for each row again doing subs_text(qr{(.+?)\t}m,"col"). the problem im getting is first two columns are get converted but not the last column because of absence of tab at last. I have managed to convert last column with "col" by getting last child of the row which is text and then wrap it with "col" value. Am I doing right. I think this will be done more easier than what i have done. If so How?

My second question is:

If i already have some elements inside the same content given above. For example,

Input: <thead> abc <ex>bcd</ex> <lp>def</lp> abc <ex>bcd</ex> def abc bcd def </thead> OUTPUT: <thead> <row><col>abc</col><col><ex>bcd</ex></col><col><lp>def</lp></col></row +> <row><col>abc</col><col><ex>bcd</ex></col><col>def</col></row> <row><col>abc</col><col>bcd</col><col>def</col></row> </thead>

For the above code each "\n" is for the row separation but i m not able to convert the input into the required output. I dont know how to select the content upto tab space. I face problem only when a tab space is between two elements.

Please give me suggestions for the above questions.

Thanks in advance

--Murugesan.


In reply to AGAIN XML::Twig tag conversion by murugu

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.