开发者

converting into XML

I am trying to convert a conversation I downloaded from Wikipedia into XML. I used the special export to get the page in XML format... that works great until I get to the main conversation.

<c开发者_开发问答onversation>
    {{PersonA|Cheese}}
    {{PersonB|I like it too...}}
    {{PersonA|Cheese?}}
</conversation>

Thats not the real conversation... anyway, I'm wondering whats the easiest way to convert a MASSIVE conversation like that into valid XML?

<conversation>
    <personA>Cheese</personA>
    <personB>I like it too...</personB>
    <personA>Cheese?</personA>
</conversation>

Thanks, this is far too long to do it manually. I'm guessing regex can help out... somehow.


Pattern:

\{\{(.*?)\|(.*?)\}\}

Replace:

<$1>$2</$1>

This is a simple solution that will fit your sample, but depending on the exact format, a more complex expression may be needed. E.g., what if a name contains a pipe? What if the text contains two closing curly brackets? Can text span multiple lines?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜