Home > Mobile >  Please god to give directions, read the following c # code to modify the XML file into QT language,
Please god to give directions, read the following c # code to modify the XML file into QT language,

Time:09-24

Here is my written in C # read XML format file, need to replace C with node, all the oldname string with newname, then oldname in the name of the file also with newname, also ask god to help



XmlDocument doc=new XmlDocument ();
XmlReaderSettings Settings=new XmlReaderSettings ();
Settings. IgnoreComments=false;
String oldname;
String newname.
XmlWriterSettings set=new XmlWriterSettings ();
Set the Indent=true; ?
XmlReader reader1=XmlReader. Create (" settlement "+ oldname +". The XML ", Settings).

Doc. The Load (reader1);
XmlNodeList nodeList=doc. SelectNodes ("////a/b/c ");
for (int i=0; IReader1. Close ();
Using (XmlWriter stw1=XmlWriter. Create (" settlement "+ newname +". The XML ", set ")
{
Doc. Save (stw1);
}

CodePudding user response:

This, and string substitution is ok

CodePudding user response:

reference 1/f, it is a nice nickname response:
, this, string substitution can now
replace under the qt test today, but I like the 3 C child node was not found

CodePudding user response:

My XML file like this, several nodes c, 15, and I need to replace it please god help me have a look, thank you very much??
& lt; a>
& lt; B>
& lt; c>
& lt; You & gt; .
& lt; I & gt; .
& lt; It & gt; D/files/15 & lt;/it & gt;
& lt;/c>
& lt; c>
& lt; You & gt; .
& lt; I & gt; .
& lt; It & gt; D/files/15 & lt;/it & gt;
& lt;/c>

CodePudding user response:

reference 1/f, it is a nice nickname response:
, this, string substitution can now
great god see, this is my replacement string of code below c node
If (node nodeName ()=="c")
{
QString STR.
STR=reader. ReadElementText ();
if(! STR. The contains (oldname))
{
STR=STR. Replace (oldname, newname);
}
}

  •  Tags:  
  • Qt
  • Related