-
Notifications
You must be signed in to change notification settings - Fork 5
AnnoMods.BBDom: Basics
taubenangriff edited this page Mar 13, 2024
·
2 revisions
using var inStream = new MemoryStream();
var doc = BBDocument.LoadStream(inStream);BBDocument doc;
using var outStream = new MemoryStream();
doc.WriteToStream(outStream);V3 is used as the default version.
To use a custom version for writing, use:
doc.WriteToStream(outStream, BBDocumentVersion.V3);BBDocument doc;
//create Nodes
var tag = doc.CreateTag("MyNodeName");
var attrib1 = doc.CreateAttrib("MyAttribName");
var attrib2 = doc.CreateAttrib("MyAttribWithContent", 53);
var stringAttrib = doc.CreateAttrib("MyStringAttribName", "Content", Encoding.UTF8);
//create Node Structure
tag.AddChildren(attrib1, attrib2, stringAttrib);
doc.AddRoot(tag);For serialization to a stream, you do
BBDocument doc;
MyType obj;
BBConvert.SerializeObject(obj, new BBSerializerOptions(), new MemoryStream());If you wish to instead serialize to a BBDocument, you can do the following:
BBDocument doc;
MyType obj;
BBConvert.SerializeObjectToDocument(obj, new BBSerializerOptions());BBDocument doc;
XmlDocument xmlDoc = doc.ToXmlDocument(); XmlDocument doc;
BBDocument bbDoc = doc.ToBBDocument();