1

complete xml newbie here...

I am attempting to create a screenwriting program. I envision it as a richtextbox where depending on the start position of the first character and/or formating of the line it is determined what kind of tag it should get in xml.

the user does not enter any tags - the user just types the words. I have included an example of what the text would look like.

there are :

  • TRANSITIONS :"Fade In:"
  • SLUGLINES :"EXT. ..." and "INT. ..."
  • CUEs :"DANI" and "FLORENCE"
  • PARENTHESIS: () for Dani in this example
  • ACTION: "two figures ..." and "Florence has ..." and "a loud crack" etc etc

so the question is : how do I translate this into xml? the tags/nodes in the xml would be named "transition", "slugline", "cue","parenthesis", "action"

there can be any number of tags of all kinds, in any kind of order.

I'm assuming the xml would look something like this :

<?xml version="1.0" encoding="utf-8" ?>
<Transition>FADE IN:</Transition>
<Act>
  <ActName>ACT I</ActName>
  <SlugLine>
    <SluglineText>EXT. FOREST - NIGHT</SluglineText>
    <Action>Two figures - teenagers- walk side by side, their flashlight     piercing the darkness.
      DANI (16) and FLORENCE (16) look scared.  The noises from the nightly forest are disconcerting.</Action>
    <Cue>DANI</Cue>
      <parenthesis>(exasperated)</parenthesis>
      <dialogue>Why did you not pack the map?  We've been walking for hours!  I'm tired and I've got blisters on my feet.</dialogue>
    <Action>Florence has obviously been crying, her eyes are red.  Inflamed looking even.</Action>
    <Cue>FLORENCE</Cue>
      <dialogue>I'm sorry, okay - how often do I have to apologise?  I just forgot!</dialogue>
    <Action>A loud CRACK behind them - they shriek!</Action>
    <Action>The previous conversation all but forgotten, they hide behind a bush, huddled together.</Action>
  </SlugLine>
</Act>

I haven't got a clue - like I said, complete xml newbie. xml might not even be the best way to go about it! any help would be greatly appreciated!

enter image description here

  • Sure it's possible. I would serialization. Do you require these nodes to be in some order? Do the nodes need to be called like that or can you have a generic name with an attribute describing the type? Perhaps it would help if you pasted an example of xml for the above case. – djv Feb 25 '20 at 20:07
  • 1
    thanks for your quick reply! I have edited my original question! the nodes could really be all over the place - multiple actions within a single slugline, same for dialogue and cue. within acts you could have multiple sluglines. it's pretty complex... – sven liegeois Feb 25 '20 at 20:25
  • 1
    My struggle with this is the order of the elements. I usually tackle this sort of problem with Xml Serialization however that alone won't guarantee element order. [It's possible with a schema](https://stackoverflow.com/q/4328867/832052) but I don't see that happening there. It could probably be done with XDocument, but I don't have any experience with that. – djv Feb 25 '20 at 20:31
  • thanks DJV! I have much to learn it seems! I hope some more posters will give me some good advice like you have. – sven liegeois Feb 25 '20 at 20:32
  • Could I ask, why do you need it to be xml? Why not just read in the data as the user entered it and parse it like that? – Hursey Feb 25 '20 at 22:57
  • @Husey : I thought xml was the way to go because of its flexibility in structure. The other parts of the application (adding resources such as props, vehicles...).would need to be tagged as children of the sluglines. What way would you suggest to save the data? – sven liegeois Feb 26 '20 at 09:07

0 Answers0