Skip to content

ReaderNode

涼月蒼菜 edited this page Sep 24, 2020 · 3 revisions

Nodes

Get the node as SavannahXmlNode.

Sample XML

<?xml version="1.0" encoding="UTF-8"?>
<ServerSettings>
  <property name="ServerName" value="My Game Host">
    Whatever you want the name of the server to be.
  </property>
  <property name="ServerName2" value="My Game Host">
    Whatever you want the name of the server to be.
  </property>
  <property name="ServerDescription" value="A 7 Days to Die server">
    Whatever you want the server description to be, will be shown in the server browser.
  </property>
  <property name="ServerWebsiteURL" value="">
    Website URL for the server, will be shown in the serverbrowser as a clickable link.
  </property>
</ServerSettings>

Get the root node

var root = reader.GetAllNodes();

Console.WriteLine(root.TagName);
Console.WriteLine(root.ChildNodes.FirstOrDefault()?.TagName);
> ServerSettings
> property

Get some nodes

Get some nodes as IEnumerable<SavannahXmlNode>.

var nodes = reader.GetNodes("/ServerSettings/property[contains(@name, 'ServerName')]");
foreach (var node in nodes)
    Console.WriteLine(node.Attributes.FirstOrDefault()?.Value);
ServerName
ServerName2

Get the node

var node = reader.GetNode("/ServerSettings/property[contains(@name, 'ServerName')]");
Console.WriteLine(node.Attributes.FirstOrDefault()?.Value);
ServerName
Clone this wiki locally