Easier way to get raw xml?
Is there a simpler way to capture the raw xml data from an element?
For example:
eiEvent := evt.FindElement(".//eiEvent" + eiFilter)
.
.
.
rawXML := etree.NewDocumentWithRoot(eiEvent)
ev.RawXML, _ = rawXML.WriteToString() // this will remove the event from the orig doc
eiEvent.Text() doesn't seem to return anything. Just trying to store the blob data for that particular element.
Thanks
The Text() function returns the character data after an XML element's opening tag and before the next XML tag. There are two cases to consider. I suspect your case is the second case.
Case 1. Consider the following XML document:
<doc>
<eiEvent>description</eiEvent>
</doc>
In this case, Text() will return "description".
Case 2. Now consider this document:
<doc>
<eiEvent>
<data>description</data>
</eiEvent>
</doc>
In this case, Text() returns the whitespace between <eiEvent> and <data>.
If the XML between an element's opening tag (<eiEvent>) and closing tag (</eiEvent>) contains tokens other than just character data, then you'll need to reserialize the element's children the way you've done it.