-1

I want to implement this feature in C#.

I have a sentence in spin format :

{My name is PapyRef and I am a {member|user|visitor} on this {forum|website|site} and I am loving it | I am admin and I am a {supervisor|admin|moderator} on this {forum|website|site} and I am loving it}

I want to generate an xml document that contains this spinning text.
For example:

<SpinItem>
    <Item>
       <Text>My name is PapyRef and I am a</Text>
    </Item>
    <SpinItem>
       <Text>member</Text>
       <Text>user</Text>
       <Text>visitor</Text>
    </SpinItem>
    <SpinItem>
       <Text>forum</Text>
       <Text>website</Text>
       <Text>site</Text>
    </SpinItem>
    <Item>
       <Text> and I am loving it </Text>
    </Item>
</SpinItem>
<SpinItem>
    <Item>
       <Text> I am admin and I am a </Text>
    </Item>
    <SpinItem>
        <Text>supervisor</Text>
        <Text>admin</Text>
        <Text>moderator</Text>
     </SpinItem>
     <SpinItem>
        <Text>forum</Text>
        <Text>website</Text>
        <Text>site</Text>
     </SpinItem>
     <Item>
        <Text> and I am loving it</Text>
     </Item>
</SpinItem>

I want to convert spinning text (italicized text) into XML format.

How can do this in C#?

LeMoussel
  • 5,290
  • 12
  • 69
  • 122
  • 6
    "spinning" in what context? Web? HTML? SVG? WebGL? Fill in some blanks here. – Reacher Gilt Jan 08 '13 at 20:16
  • 4
    After addressing @ReacherGilt 's points, please tell us what you have tried. Where are you getting stuck? Do you know how to read XML files? stackoverflow is generally for questions that go beyond "write it for me". – Jonathan Wood Jan 08 '13 at 20:17
  • 1
    Are you saying that you want C# to convert that italicized text there into the XML you're showing? – JLRishe Jan 08 '13 at 20:20
  • 1
    [What have you tried?](http://whathaveyoutried.com) – Bobson Jan 08 '13 at 20:22
  • The desired result looks overly complicated: the whole point of XML is that you can *mix* text with data in a semi-structured schema. You should omit all your `` nodes, they add nothing. Also, the ``s don’t work the way you want them to. You need to replace the `` nodes inside by dedicated `` nodes, otherwise the schema cannot distinguish between concatenation and alternation of text. – Konrad Rudolph Jan 08 '13 at 20:22
  • @JLRishe Yes. @ Konrad Rudolph. OK. I Update my example. – LeMoussel Jan 08 '13 at 21:16
  • @PapyRef You’ve made the XML *more* complex instead of less and you haven’t corrected the mistaks in the schema. – Konrad Rudolph Jan 09 '13 at 09:37
  • @ Konrad Rudolph I do not understand where is the error. Can you give an example of simplification and correct error – LeMoussel Jan 09 '13 at 21:01

1 Answers1

0

Top-down parsing should help you. Here are few similar questions:

Community
  • 1
  • 1
k0stya
  • 4,267
  • 32
  • 41