Now that I am looking at what you wrote down here as an example again, I think what might be going on is that you are actually using MultiMarkdown’s .fodt XML output as a way of generating XML output from Scrivener? As a word processing document format, that’s probably not the kind of XML you are looking for. It sounds more like you are wanting to get the structure of your document out of Scrivener as XML?
Using Native Scrivener XML
So, one very straight-forward answer to your question then is: Scrivener already stores your binder information in XML. You could write an XSLT script to extract it, or use some other scripting language if you wished. You can take a look by opening the “project name.scrivx” file, or what you would normally double-click on to load in Scrivener, in an XML editor.
Example native Scrivener XML...
<BinderItem UUID="7830FA08-AD8F-41E3-8508-A496E638EDDC" Type="Text" Created="2020-02-17 14:16:15 +0200" Modified="2021-09-06 19:45:08 +0200">
<Title>Name of item in Binder</Title>
<MetaData>
<LabelID>1</LabelID>
<StatusID>2</StatusID>
</MetaData>
</BinderItem>
The label and status information is found further down in the file:
<LabelSettings>
<Title>Label</Title>
<DefaultLabelID>-1</DefaultLabelID>
<Labels>
<Label ID="-1">No Label</Label>
<Label ID="0" Color="0.993500 0.701213 0.732586">Red</Label>
<Label ID="1" Color="0.995422 0.790951 0.652384">Orange</Label>
<Label ID="2" Color="0.997726 0.892729 0.652567">Yellow</Label>
<Label ID="3" Color="0.715862 0.948714 0.697688">Green</Label>
<Label ID="4" Color="0.702312 0.888273 0.974258">Blue</Label>
<Label ID="5" Color="0.957565 0.766751 0.999619">Purple</Label>
</Labels>
</LabelSettings>
<StatusSettings>
<Title>Status</Title>
<DefaultStatusID>-1</DefaultStatusID>
<StatusItems>
<Status ID="-1">No Status</Status>
<Status ID="0">To Do</Status>
<Status ID="1">In Progress</Status>
<Status ID="2">First Draft</Status>
<Status ID="3">Revised Draft</Status>
<Status ID="4">Final Draft</Status>
<Status ID="5">Done</Status>
</StatusItems>
</StatusSettings>
Creating an XML Compile Format
But if you are not familiar with scripting languages, processing that file to a form you want may be too much work, and the compiler will be better. I can think of a couple of ways to do this that might work better than what you were trying.
Modified Pandoc DocBook
The first is to use Pandoc’s DocBook conversion, rather than MMD’s FODT. As I say the second one is for word processing, it will be very messy. The first is much cleaner, and closer to HTML.
I have attached a simple example of how you can insert custom XML into the DocBook XML Pandoc creates:
<section xml:id="scene-a">
<title>scene a</title>
<label>Orange</label>
<status>First Draft</status>
<para>
Dri srung gronk ozlint; zeuhl la, ti dri. Relnag xi nalista dri
lydran wynlarce, prinquis zorl nalista, zeuhl re obrikt relnag
erk wynlarce wex pank gronk? Menardis clum, morvit xu ma yem
twock irpsa ma cree tolaspa. Erk teng flim obrikt; menardis nix
frimba tharn nalista kurnap rhull.
</para>
</section>
DocBook-plus.zip (3.7 KB)
- To see how this works, first open compile in your project, and click the gear button at the bottom of the left side bar, choosing “Import Formats…”. Select the unzipped copy of the sample.
- Switch to Compile for: “Pandoc → DocBook” at the top of the window.
- Double-click on the “DocBook (Plus)” example format I created for you, in the left sidebar of the compile window.
- In the “Section Layouts” pane, you will find the two layouts being used. Click on one of them, and examine the “Prefix” tab.
This is how we can tell Pandoc to insert raw XML into the file. We are using the Prefix tab because it will insert this information right after the title, but it could be put anyway. The Suffix tab beside it is also nice for this kind of thing, if the XML should follow the text body.
Custom XML Generator
The last option is to create your own compile format in Scrivener, using the Plain-Text file type as an option. As you may be seeing now from the type of fields in Section Layout, Scrivener was designed to be capable of generating valid XML files as a kind of design goal. We figured if the compile to create custom XML, it could create just about any kind of text markup out there. You will find prefix and suffix fields around sections, around titles and around styled text.
If you want a simple demonstration, let me know.