开发者

Why doesn't my code want to add any more child nodes? (XML)

I'm coding a program to translate a game. The original string and the translated string get saved to an XmlDocument, which can be saved to a file when the user clicks a button.

Everything works fine until a certain number of nodes (30?) or until it reaches a certain size (8192 bytes?), then it just stops adding nodes to the XmlDocument.

My code: http://lesderi开发者_如何转开发d.pastebin.com/zgcT9PVu.

An XML file: @character.lua.Decoded.VOQ.xml


There doesn't seem to be any problem i tried your code and i got correct output.. so problem is somewhere else.


I tried this (In LINQPAD) and Got 100 Elements (10,349 Bytes)

XmlDocument XmlDoc;
XmlElement mainStringsNode;


void Main()
{
    XmlDoc = new XmlDocument(); 
    XmlNode xmlDeclarationNode = XmlDoc.CreateXmlDeclaration("1.0", "UTF-8", null); 
    XmlDoc.AppendChild(xmlDeclarationNode); 
    mainStringsNode = XmlDoc.CreateElement("Strings");  
    XmlDoc.AppendChild(mainStringsNode);    
    var docWriter = new StringWriter(); 
    XmlDoc.Save(docWriter);
    for(int i=0; i < 100; i++)      AddStringChild(i, "satr", "edited");    
    XmlDoc.Dump();      
}
private void AddStringChild(int id, string originalString, string editedString)
{
        XmlNode stringNode = XmlDoc.CreateElement("String");
        var posAttribute = XmlDoc.CreateAttribute("position");
        posAttribute.Value = id.ToString();
        if (stringNode.Attributes != null) stringNode.Attributes.Append(posAttribute);
        mainStringsNode.AppendChild(stringNode);
        var originalStringNode = XmlDoc.CreateElement("OriginalString");
        originalStringNode.AppendChild(XmlDoc.CreateTextNode(originalString));
        stringNode.AppendChild(originalStringNode);
        var editedStringNode = XmlDoc.CreateElement("EditedString");
        editedStringNode.AppendChild(XmlDoc.CreateTextNode(editedString));
        stringNode.AppendChild(editedStringNode);
}

Output:

<?xml version="1.0" encoding="UTF-8"?><Strings><String position="0"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="1"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="2"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="3"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="4"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="5"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="6"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="7"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="8"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="9"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="10"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="11"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="12"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="13"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="14"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="15"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="16"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="17"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="18"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="19"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="20"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="21"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="22"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="23"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="24"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="25"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="26"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="27"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="28"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="29"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="30"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="31"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="32"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="33"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="34"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="35"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="36"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="37"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="38"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="39"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="40"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="41"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="42"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="43"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="44"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="45"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="46"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="47"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="48"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="49"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="50"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="51"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="52"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="53"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="54"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="55"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="56"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="57"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="58"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="59"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="60"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="61"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="62"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="63"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="64"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="65"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="66"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="67"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="68"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="69"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="70"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="71"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="72"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="73"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="74"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="75"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="76"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="77"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="78"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="79"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="80"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="81"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="82"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="83"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="84"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="85"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="86"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="87"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="88"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="89"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="90"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="91"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="92"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="93"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="94"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="95"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="96"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="97"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="98"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String><String position="99"><OriginalString>satr</OriginalString><EditedString>edited</EditedString></String></Strings>
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜