EDN Admin
Well-known member
Hi All,
I need to update the XML file with Translated string. I have one two dimensional array called XMLArray [,] and XML file.
If I found XMLArray[0,0] value in XML file, then need to replace XMLArray[0,1] value with it.
Please find the code below. At present my code is working fine, but when i upload huge file, its taking too much time. looping process is taking too much time. I am looking
optimized code. <span style="font-size:x-small if anyone resolve this issue it, will be the great.
<pre>string XMLArrayString="",XMLTString="";
for (int xmlLoop = 0; xmlLoop <= XMLLength - 1; xmlLoop++)
{
if (XMLArray[xmlLoop, 0] != null)
{
XMLArrayString = XMLArray[xmlLoop, 0].ToString();
XMLTString = XMLArray[xmlLoop, 1].ToString();
{
strExist = false;
intcount = 0;
foreach (XmlElement QPageEle in QPelements)
{
string strele = QPageEle.Name;
if (QPageEle.HasChildNodes)
{
for (int CNode = 0; CNode < QPageEle.ChildNodes.Count; CNode++)
{
if (QPageEle.ChildNodes[0].Name == "ComponentTitle")
{
XmlNodeList Qnode = QPageEle.ChildNodes[0].SelectNodes("//ComponentTitle/DisplayText/Localized/Content");
foreach (XmlElement qnod in Qnode)
{
string XMLString = qnod.InnerText.Trim();
if (XMLString == "How did this survey-taking experience compare to other online surveys you have taken?")
break;
if (XMLArrayString == XMLString)
{
qnod.InnerText = XMLTString == "" ? XMLArrayString : XMLTString;
strExist = true;
break;
}
}
}
if (QPageEle.ChildNodes.Count > 0)
{
if (QPageEle.ChildNodes[CNode].Name == "Answers" || QPageEle.ChildNodes[CNode].Name == "Prompts" || QPageEle.ChildNodes[CNode].Name == "Headings")
{
XmlNodeList Ansnodes1 = QPageEle.ChildNodes[CNode].SelectNodes("DisplayText/Localized/Content");
foreach (XmlElement anode in Ansnodes1)
{
string ansString = anode.InnerText.Trim();
if (ansString == XMLArrayString)
{
anode.InnerText = XMLTString == "" ? XMLArrayString : XMLTString;
strExist = true;
break;
}
}
}
}
}
}
intcount++;
if (strExist == true)
break;
}
}
}
}
XMLDoc.Save(strTXML);
[/code]
<hr class="sig Chinni Krishna
View the full article
I need to update the XML file with Translated string. I have one two dimensional array called XMLArray [,] and XML file.
If I found XMLArray[0,0] value in XML file, then need to replace XMLArray[0,1] value with it.
Please find the code below. At present my code is working fine, but when i upload huge file, its taking too much time. looping process is taking too much time. I am looking
optimized code. <span style="font-size:x-small if anyone resolve this issue it, will be the great.
<pre>string XMLArrayString="",XMLTString="";
for (int xmlLoop = 0; xmlLoop <= XMLLength - 1; xmlLoop++)
{
if (XMLArray[xmlLoop, 0] != null)
{
XMLArrayString = XMLArray[xmlLoop, 0].ToString();
XMLTString = XMLArray[xmlLoop, 1].ToString();
{
strExist = false;
intcount = 0;
foreach (XmlElement QPageEle in QPelements)
{
string strele = QPageEle.Name;
if (QPageEle.HasChildNodes)
{
for (int CNode = 0; CNode < QPageEle.ChildNodes.Count; CNode++)
{
if (QPageEle.ChildNodes[0].Name == "ComponentTitle")
{
XmlNodeList Qnode = QPageEle.ChildNodes[0].SelectNodes("//ComponentTitle/DisplayText/Localized/Content");
foreach (XmlElement qnod in Qnode)
{
string XMLString = qnod.InnerText.Trim();
if (XMLString == "How did this survey-taking experience compare to other online surveys you have taken?")
break;
if (XMLArrayString == XMLString)
{
qnod.InnerText = XMLTString == "" ? XMLArrayString : XMLTString;
strExist = true;
break;
}
}
}
if (QPageEle.ChildNodes.Count > 0)
{
if (QPageEle.ChildNodes[CNode].Name == "Answers" || QPageEle.ChildNodes[CNode].Name == "Prompts" || QPageEle.ChildNodes[CNode].Name == "Headings")
{
XmlNodeList Ansnodes1 = QPageEle.ChildNodes[CNode].SelectNodes("DisplayText/Localized/Content");
foreach (XmlElement anode in Ansnodes1)
{
string ansString = anode.InnerText.Trim();
if (ansString == XMLArrayString)
{
anode.InnerText = XMLTString == "" ? XMLArrayString : XMLTString;
strExist = true;
break;
}
}
}
}
}
}
intcount++;
if (strExist == true)
break;
}
}
}
}
XMLDoc.Save(strTXML);
[/code]
<hr class="sig Chinni Krishna
View the full article