I have XML data in a XmlDataDocument and i want to merge
them into another existing XmlDataDocument.
I have to insert and update data in the existing
XmlDataDocument.
In my code this.DictionaryDocument is of type
XmlDataDocument (the existing one).
I am using XmlDataDocument because i have a GUI where i
present the resulting data and a grid where i can bind the
dataset property of the XmlDataDocument!
with the code fragment:
"XmlElement root =
this.DictionaryDocument.DocumentElement;
ls = @"/*/DicEntry[@TextKey=" +
TTUtility.GetXPathConcatParamList(this.TextKey) + "]
[@KeyDependency=" + TTUtility.GetXPathConcatParamList
(this.CurrentMergeNode.Attributes.GetNamedItem
("KeyDependency").Value.ToString()) + "]/*[name()=" +
TTUtility.GetXPathConcatParamList(mNode.Name) + "]";
lNode = root.SelectSingleNode(ls);"
....i get the node in the existing XmlDataDocument that i
want to update (before i testet if there is one!)
thanks,
John
-----Original Message-----
Where are you using XmlDataDocument? It is not obvious
from your code.Anyway, XmlDataDocument is not nearly as performance
optimized as anXPathDocument for example. Have you tried reading the Xml
from the DataSetinto an XPath doc or a regular XmlDocument to do the
merge?
--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor
"John R." <rj@hcdv.at> wrote in message
news:10****************************@phx.gbl... I have an application written in C# and i am using MS
XML DOM!
I have a document with the following structure (only the
<DicEntry> - Elements are important):
<NewDataSet xmlns:xsi="http://www.w3.org/2001/XMLSchema-
instance">
.
<DicEntry TextKey="Test1" KeyDependency="True">
<default>Test1</default>
<de>Button Germanmanuell</de>
<it />
</DicEntry>
<DicEntry TextKey="Dialog1" KeyDependency="True">
<default>Dialog1</default>
<de />
<it />
</DicEntry>
.
</NewDataSet>
I now want to merge such a document with a document of
type XmlDataDocument with the same structure in memory!
There is the main code:
XmlElement root =
this.DictionaryDocument.DocumentElement; //bei Formbezogene "TextKey" = "default"
ls = @"/*/DicEntry[@TextKey=" +
TTUtility.GetXPathConcatParamList(this.TextKey) + "]
[@KeyDependency=" + TTUtility.GetXPathConcatParamList
(this.CurrentMergeNode.Attributes.GetNamedItem
("KeyDependency").Value.ToString()) + "]/*[name()=" +
TTUtility.GetXPathConcatParamList(mNode.Name) + "]";
lNode = root.SelectSingleNode(ls);
The method GetXPathConcatParamList builds a
parameterlist for the Xpath method concat.
/// <summary>
/// this method builds a parameterlist for the Xpath
method concat,
/// so that the method SelectSingleNode can also
work (search) on
/// elements, attributes with double quotation marks
in their names.
/// </summary>
/// <param name="aValue">a string</param>
/// <returns>concat condition for SelectSingleNode
method</returns>
public static string GetXPathConcatParamList(string
aValue)
{
char[] lSplit = new char[1] {'"'};
string[] lSplitValues={""};
int lSplitValuesLen;
string lReturn="";
string lValue="";
string lHelp="";
//replace " in aValue with "
lValue = aValue.Replace(""", "\"");
//split with "
lSplitValues = lValue.Split(lSplit);
lSplitValuesLen = lSplitValues.Length;
//if there is no double quotation mark then return
//and there is no build for concat
if(lSplitValuesLen == 1)
{
lReturn = "\"" + aValue + "\"";
}
else //build parameterlist for method concat
{
for (int i = 0; i <= lSplitValuesLen - 1; i++)
{
if(i==lSplitValuesLen - 1)
lHelp = lHelp + "\"" + lSplitValues[i]
+ "\""; else
lHelp = lHelp + "\"" + lSplitValues[i]
+ "\"" + "," + "'\"'" + ",";
}
lReturn = "concat(" + lHelp + ")";
}
return lReturn;
}
Performance results:
Merging 10 <DicEntry> - Elements into 100
in memory => ca. 1 sec.
Merging 10 <DicEntry> - Elements into 500
in memory => ca. 6 sec.
Merging 10 <DicEntry> - Elements into 1000 in
memory => ca. 12 sec.
Merging 100 <DicEntry> - Elements into 100
in memory => ca. 21 sec.
Merging 100 <DicEntry> - Elements into 1000 in
memory => ca. 190 sec.
Merging 1000 <DicEntry> - Elements into 1000 in
memory => ca. over 3600 sec.
The method "SelectSingleNode" takes time of 96 % of the
applications running time!!!!!!!!!!!!!!!!!!!!!
Please can you help on this problem?
thanks,
john
.