473,616 Members | 2,973 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

performance problem with SelectSingleNod e

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 6045
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>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 &quot; in aValue with "
lValue = aValue.Replace( "&quot;", "\"");

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

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

.

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
1728
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 the item element. They ALL contain the nodes: title, description, link and pubDate. But they come in all different orders and have other child nodes sandwiched among the ones I am after.
2
9861
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" xmlns="mailto:neo_in_matrix@msn.com?subject=ssmprjx" > <pr>
4
1676
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 xml file, but repeats the first one 3 times. I'm sure its something minor but i just cant seem to figure it out. here is the XML, and source code below:
4
4955
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 nunit test that exposes the problem. I have run the test under both the 1.0 and 1.1 framework with the same result. public void XPathBooks() { XmlDocument smallDoc = new XmlDocument();
0
1209
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: 'xmlDoc.selectSingleNode(...)' Any help would be appreciated. Here is my code that realtes to this issue:
7
1243
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 the CD node) ? thank you very much Sharon <Catalog> <Cd category="rock">
1
1604
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 XPath query (note I may be using the wrong terminology - I don't use XML very often). The function then uses that XPath query with SelectSingleNode
3
1834
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: 1.) Request an Async request of the XML 2.) Once complete, parse the appropriate XML data to parse
0
1797
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. .Load(pcXmlFile) oPackage = .documentElement.SelectSingleNode("//Package")
0
8203
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8647
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8592
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
7121
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6097
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5550
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4141
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2579
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
0
1445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.