I have already read through some replies on this site, but none of them works for me I have an XML file like this:
& lt; Root & gt; & Lt; Character & gt; & Lt; Name & gt; Volstvok & lt; / Name & gt; & Lt; CharID & gt; (Omitted) & lt; / CharID & gt; & Lt; UserID & gt; (Omitted) & lt; / UserID & gt; & Lt; ApiKey & gt; (Omitted) & lt; / ApiKey & gt; & Lt; / Character & gt; & Lt; / Root & gt; Let me know someone else & lt; Character & gt; must be added
I'm trying this but it does not work:
public zero addCharacter (string name, int id, int userID, string APKY) {Element newCharacter = doc. CreateElement ("character"); Element new name = doctor .cent element ("name"); NewName.setTextContent (name); Element new id = doc.createElement ("charID"); NewID.setTextContent (Integer.toString (id)); Element new userid = doc.createElement ("userID"); NewUserID.setTextContent (Integer.toString (userID)); Element NAPIK = Doc.Scent Element ("APKY"); NewApiKey.setTextContent (apiKey); // Setup and type a new one. AppendChild (newName); NewCharacter.appendChild (newID); NewCharacter.appendChild (newUserID); NewCharacter.appendChild (newApiKey); . Doc.getDocumentElement () appendChild (newCharacter); }
Without seeing all your code, I suspect that the problem is that You are adjusting in in-memory DOM, but do not type the result back in the file.
Write something like this:
Transformerfacture NUE Instance (). Nautronformer (). Transform (new dosource (doctor), new stream result (f)); Where is the doctor is a document, and file to write f .
Find the special element in the DOM, I suggest.
Comments
Post a Comment