What am I doing wrong here when using GXml.DomNode.text_content? I would’n have expected to concatenate the strings:
Period:
<?xml version="1.0"?>
<Period unit="ms">25</Period>
Period:
<?xml version="1.0"?>
<Period unit="ns">25625</Period>
results from:
public class Period : GXml.Element {
private const string NODE_NAME = "Period";
public int period {
get { return (int.parse(text_content)); }
set { text_content = value.to_string(); }
}
public string unit {
owned get { return get_attribute("unit"); }
set { set_attribute("unit", value); }
}
public Period(int p, string u) {
unit = u;
period = p;
}
construct {
// This is the Element's node's name to be used
try { initialize (NODE_NAME); }
catch (GLib.Error e ) {
warning ("Error: "+e.message);
}
}
}
void main () {
try {
var p = new Period(25, "ms");
stdout.printf ("Period:\n\n%s\n", p.write_string());
p.period = 625;
p.unit = "ns";
stdout.printf ("Period:\n\n%s\n", p.write_string());
} catch (GLib.Error e) {
warning ("Error: "+e.message);
}
stdout.printf("\n");
}