473,386 Members | 1,798 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

performance problem with SelectSingleNode

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">
Nov 11 '05 #1
3 6008
Where are you using XmlDataDocument? It is not obvious from your code.
Anyway, XmlDataDocument is not nearly as performance optimized as an
XPathDocument for example. Have you tried reading the Xml from the DataSet
into 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 &quot; in aValue with "
lValue = aValue.Replace("&quot;", "\"");

//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

Nov 11 '05 #2
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

.

Nov 11 '05 #3
John R. wrote:
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.


Obviously you can get better XPath expression evaluation performance using
XPathDocument instead, which is specially optimized for that. But you cannot
update XPathDocument, because it's read-only by definition.
Also you can try to simplify your XPath expression.
--
Oleg Tkachenko
http://www.tkachenko.com/blog
Multiconn Technologies, Israel

Nov 11 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: gordon.lear | last post by:
I am using MSXML 4.0 I am grabbing numerous RSS News Feeds and trying to parse the data and read it into a dB. The problem is that the RSS News feeds are not all the same when tunneled down in...
2
by: Edward Yang | last post by:
My XML document has a default namespace specified by xmlns="some_url". Here it is: <?xml version="1.0" encoding="utf-8" ?> <ssmproject name="sample" server="sql"...
4
by: Paul M | last post by:
Larry, i've got an xml file which has multiple cities as the top level item. When i read it in using XMLReader, and define the variables, as below, it finds the correct number of cities in the...
4
by: Rune | last post by:
I have two queries that appear to be exactly the same, but one of them returns null while the other one returns a valid result! Can anyone provide an explanation to why this is so? Below is an...
0
by: Savaticus | last post by:
This is VBScript centric I have an issue where in windows 2k the selectSingleNode method returns values as expected but in Windows XP I get an error Object Required:...
7
by: Sharon | last post by:
hi guys , I'm mew to system.xml my question is : what is the right way to read / write value to the "First_Name" node ? and same question : how do I read/ write to the category property (inside...
1
by: mjwills | last post by:
All, I am tearing my hair out on this one. I've checked Google and the newsgroups, and can't seem to solve it... My problem: I have an XML document that I pass to another function with an...
3
by: christopher.davidson | last post by:
Hello, I am working with XML files and utilizing Array functions to take the XML data and combined it with some html code to display a particular page. The process currently works like so: ...
0
by: compumate99 | last post by:
I am trying to parse the xml document using selectsinglenode method. I am doing this using Visual Foxpro >>> loResultXml = CreateObject("Microsoft.XMLDOM") With loResultXml .Async = .F. ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.