For example, I have this chunk of text from a XML file :
<text:p text:style-name="P1">Some text</text:p>
I am able to parse the paragraph elements with this code :
dim x as new XmlDocument
Var nodes As XmlNodeList
nodes = x.XQL("//text:p") // Find paragraph elements in XML
// Loop through results and display each name attribute
Var node As XmlNode
For i As Integer = 0 To nodes.Length - 1
node = nodes.Item(i)
if node.GetAttribute("text:style-name") = "P1" then
MessageBox("Paragraph: " + node.GetAttribute("text:style-name"))
end if
Next
But I don’t know yet how to get the sentence “Some text” in the paragraph “P1”.
If you use the XmlReader Class with the events, it would simplify your parsing of ODT files. With the StartElement/EndElement Event you can filter <text:p/> and with the Characters Event you‘ll get your sentence.
I obviously saw the XMLReader.xojo_binary_project file in the Sample Projects folder. But a sample source code for the Characters Event is missing and I am a newbie in that domain.
Could you suggest a generic source code for this event ?