473,403 Members | 2,071 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,403 software developers and data experts.

XML Family - sounds confusing with so many different technologies.

Hi everyone,

I am not that good in xml terms and coding in c#. To be honest.

ok, just imagine, i had this xml file.

<xml>
<language>C#</language>
<comments>cool language</comments>
<desc />
<author />
<company />
<codes />
</language>VB</language>
<comments>Never used before</comments>
<desc />
<author />
<company />
<codes />
....
....
</xml>

To search for C# keywords, i can just simple use XMLTextReader to do it.

There are few other terms, which i am so confused with.

XMLNode

XPath

XQuery

XInfer

or whatever X things? Maybe X-Men... hehe :)

I am looking for the best way to retrieve the fastest speed and best peformance when searching for a key inside the xml file.

I assume xml file is like a binary tree, BST. Correct me if i am wrong.

DTD and XSchema - i think this is more to define what is xml about? By adding a descriptive layer... hmm.. i guess so...

But again, just want to know the best way to search in a xml file which contains 10,000 <language /> tags. As i treat language as a unique key and used for searching.

No database used here. I think xml is a good way.
--
Regards,
Chua Wen Ching :)
Nov 16 '05 #1
3 1448
Use Xpath is a querying tool -- it uses a language similar to SQL for
searching for specific conditions inside of Nodes.

If you are talking about searching all nodes for anything that
references a c keyword, then yes, your going to have to iterate through
the whole document, and take a look at the nodes that interest you, and
then do a regex, or string search for the keywords.

You could use XPath if say, you created an array of all the c# keywords
that you were interested in and then created an XPath query string to
search through them all. Here's sample code for using Xpath, it takes
the XML file and the Xpath string as arguments at the line command.

using System;
using System.Xml;

namespace {
class xpathtest2
{
[STAThread]
static void Main(string[] args)
{
if(args.Length < 2)
{
Console.WriteLine("Incorrect number of parameters");
goto endApp;
}

try
{
//Load the XML document
XmlDocument doc = new XmlDocument();
doc.Load(args[0]);

//Create XPathNavigator
XPathNavigator xpathNav = doc.CreateNavigator();

//Compile the XPath expression
XPathExpression xpathExpr = xpathNav.Compile(args[1]);

//Display the results depending on type of result
switch(xpathExpr.ReturnType)
{
case XpathResultType.Boolean:
Console.WriteLine("Boolean value: {0}",
xpathNav.Evaluate(xpathExpr));
break;

}
Chua Wen Ching wrote:
Hi everyone,

I am not that good in xml terms and coding in c#. To be honest.

ok, just imagine, i had this xml file.

<xml>
<language>C#</language>
<comments>cool language</comments>
<desc />
<author />
<company />
<codes />
</language>VB</language>
<comments>Never used before</comments>
<desc />
<author />
<company />
<codes />
...
...
</xml>

To search for C# keywords, i can just simple use XMLTextReader to do it.

There are few other terms, which i am so confused with.

XMLNode

XPath

XQuery

XInfer

or whatever X things? Maybe X-Men... hehe :)

I am looking for the best way to retrieve the fastest speed and best peformance when searching for a key inside the xml file.

I assume xml file is like a binary tree, BST. Correct me if i am wrong.

DTD and XSchema - i think this is more to define what is xml about? By adding a descriptive layer... hmm.. i guess so...

But again, just want to know the best way to search in a xml file which contains 10,000 <language /> tags. As i treat language as a unique key and used for searching.

No database used here. I think xml is a good way.

Nov 16 '05 #2
Hi IBM Salesman,

Thanks for the tips. I am looking forward on XPath then.

Is there any good resources on XPath, i only found a few.

Ialso heard that Microsoft will not support XPath 2.0 but will move to XQuery 1.0.

Thanks again.
--
Regards,
Chua Wen Ching :)
"IBM Salesman" wrote:
Use Xpath is a querying tool -- it uses a language similar to SQL for
searching for specific conditions inside of Nodes.

If you are talking about searching all nodes for anything that
references a c keyword, then yes, your going to have to iterate through
the whole document, and take a look at the nodes that interest you, and
then do a regex, or string search for the keywords.

You could use XPath if say, you created an array of all the c# keywords
that you were interested in and then created an XPath query string to
search through them all. Here's sample code for using Xpath, it takes
the XML file and the Xpath string as arguments at the line command.

using System;
using System.Xml;

namespace {
class xpathtest2
{
[STAThread]
static void Main(string[] args)
{
if(args.Length < 2)
{
Console.WriteLine("Incorrect number of parameters");
goto endApp;
}

try
{
//Load the XML document
XmlDocument doc = new XmlDocument();
doc.Load(args[0]);

//Create XPathNavigator
XPathNavigator xpathNav = doc.CreateNavigator();

//Compile the XPath expression
XPathExpression xpathExpr = xpathNav.Compile(args[1]);

//Display the results depending on type of result
switch(xpathExpr.ReturnType)
{
case XpathResultType.Boolean:
Console.WriteLine("Boolean value: {0}",
xpathNav.Evaluate(xpathExpr));
break;

}
Chua Wen Ching wrote:
Hi everyone,

I am not that good in xml terms and coding in c#. To be honest.

ok, just imagine, i had this xml file.

<xml>
<language>C#</language>
<comments>cool language</comments>
<desc />
<author />
<company />
<codes />
</language>VB</language>
<comments>Never used before</comments>
<desc />
<author />
<company />
<codes />
...
...
</xml>

To search for C# keywords, i can just simple use XMLTextReader to do it.

There are few other terms, which i am so confused with.

XMLNode

XPath

XQuery

XInfer

or whatever X things? Maybe X-Men... hehe :)

I am looking for the best way to retrieve the fastest speed and best peformance when searching for a key inside the xml file.

I assume xml file is like a binary tree, BST. Correct me if i am wrong.

DTD and XSchema - i think this is more to define what is xml about? By adding a descriptive layer... hmm.. i guess so...

But again, just want to know the best way to search in a xml file which contains 10,000 <language /> tags. As i treat language as a unique key and used for searching.

No database used here. I think xml is a good way.

Nov 16 '05 #3
Chua Wen Ching wrote:
Hi IBM Salesman,

Thanks for the tips. I am looking forward on XPath then.

Is there any good resources on XPath, i only found a few.
I found this site to be most useful:

www.perfectxml.com

Ialso heard that Microsoft will not support XPath 2.0 but will move to
XQuery 1.0.
Thanks for /that/ tip!

I will have to investigate XQuery.

Thanks again.


--
w 4
Nov 16 '05 #4

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

Similar topics

23
by: Dufe | last post by:
Hello all: To deal with the problem of differing user screen resolutions, I've explored: 1) making the pages in PHP, 2) having different pages on the same page and selecting the proper one via...
7
by: Fabian Neumann | last post by:
Hi! I got a problem with font-family inheritance. Let's say I have CSS definitions like: p { font:normal 10pt Verdana; } strong { font:normal 14pt inherit;
20
by: xixi | last post by:
hi, we use db2 udb v8.1 on windows, i am trying to use federated database objects to create wrapper, even though i have update dbm cfg using federated yes, i still get error "the instance for the...
19
by: Peter T. Keillor III | last post by:
I'm not talking "Days of our Lives", only church stuff. What's the most efficient way to show relations among members, have a member table, then a relations table (member 1, member 2, relation)? ...
9
by: Lyle Fairfield | last post by:
It's confusing. Many people here and elsewhere make many different predictions: There's an introduction mentioning some aspects of this at...
11
by: cartercc | last post by:
January, 2006. I do not intend to start any kind of flame war, but only to seek advice about different technologies concerning which I am mostly ignorant. I am the database manager for a unit...
70
by: axlq | last post by:
I'm trying to design my style sheets such that my pages have similar-looking fonts different platforms (Linux, Mac, Adobe, X-Windows, MS Windows, etc). The problem is, a font on one platform...
6
by: tlendz | last post by:
Hi, I've got several divs with the same id/name, and text inside (font- family:georgia,serif), and would like the users to be able to change the font, in case they don't like the default one. I...
18
by: Cliff Chapin | last post by:
I want to create a Family database some of these "families " are single fathers with children some are single women with children they will be assigned Rooms /w children. what would be the best to...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
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...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
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...

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.