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.Dictionary Document 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.Dictionary Document.Docume ntElement;
ls = @"/*/DicEntry[@TextKey=" +
TTUtility.GetXP athConcatParamL ist(this.TextKe y) + "]
[@KeyDependency= " + TTUtility.GetXP athConcatParamL ist
(this.CurrentMe rgeNode.Attribu tes.GetNamedIte m
("KeyDependency ").Value.ToStri ng()) + "]/*[name()=" +
TTUtility.GetXP athConcatParamL ist(mNode.Name) + "]";
lNode = root.SelectSing leNode(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 anXPathDocumen t 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>Test 1</default>
<de>Button Germanmanuell</de>
<it />
</DicEntry>
<DicEntry TextKey="Dialog 1" KeyDependency=" True">
<default>Dialog 1</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.Dictionary Document.Docume ntElement; //bei Formbezogene "TextKey" = "default"
ls = @"/*/DicEntry[@TextKey=" +
TTUtility.GetXP athConcatParamL ist(this.TextKe y) + "]
[@KeyDependency= " + TTUtility.GetXP athConcatParamL ist
(this.CurrentMe rgeNode.Attribu tes.GetNamedIte m
("KeyDependency ").Value.ToStri ng()) + "]/*[name()=" +
TTUtility.GetXP athConcatParamL ist(mNode.Name) + "]";
lNode = root.SelectSing leNode(ls);
The method GetXPathConcatP aramList builds a
parameterlist for the Xpath method concat.
/// <summary>
/// this method builds a parameterlist for the Xpath
method concat,
/// so that the method SelectSingleNod e can also
work (search) on
/// elements, attributes with double quotation marks
in their names.
/// </summary>
/// <param name="aValue">a string</param>
/// <returns>conc at condition for SelectSingleNod e
method</returns>
public static string GetXPathConcatP aramList(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(lS plit);
lSplitValuesLen = lSplitValues.Le ngth;
//if there is no double quotation mark then return
//and there is no build for concat
if(lSplitValues Len == 1)
{
lReturn = "\"" + aValue + "\"";
}
else //build parameterlist for method concat
{
for (int i = 0; i <= lSplitValuesLen - 1; i++)
{
if(i==lSplitVal uesLen - 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 "SelectSingleNo de" takes time of 96 % of the
applications running time!!!!!!!!!!! !!!!!!!!!!
Please can you help on this problem?
thanks,
john
.