473,507 Members | 2,395 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML Assistance needed

Hi,
I need to store customers and their emails in an XML file for quick lookup
in a small program. I am kind of a bit confused with this XML thing. Do I use
XML or this XSD Schema?

I came up with this

<customers>
<customer>
<id>1</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
<customer>
<id>2</id>
<email>te**@test.com</email>
</customer>
<customer>
<id>3</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
</customers>

Is this useable? If yes, where do I get information on reading and writing
to XML? I couldn't find any information either on searching, ex if I want to
get all the email addresses for a specific customer (id).

Thanks
Jun 17 '07 #1
3 1387
Hi,
You can do it easily by using XMLDocument and xpath query.
Below link shows how to read xml file and also how to add nodes to it.
http://www.codeguru.com/csharp/cshar....php/c9427__1/
And below link shows how to update nodes in xml file:
http://www.dotnetspider.com/kb/Article2938.aspx.
Also i would suggest you to changes structure of your xml file to the
following:
<customers>
<customer id="1">
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
<customer id="2">
<email>te**@test.com</email>
</customer>
<customer id="3">
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
</customers>
If you are having trouble using xpath query to retreive all the email
addresses for a specific customer (id) then please do let me know
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Chris" wrote:
Hi,
I need to store customers and their emails in an XML file for quick lookup
in a small program. I am kind of a bit confused with this XML thing. Do I use
XML or this XSD Schema?

I came up with this

<customers>
<customer>
<id>1</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
<customer>
<id>2</id>
<email>te**@test.com</email>
</customer>
<customer>
<id>3</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
</customers>

Is this useable? If yes, where do I get information on reading and writing
to XML? I couldn't find any information either on searching, ex if I want to
get all the email addresses for a specific customer (id).

Thanks
Jun 17 '07 #2
Hi,
How do I find all emails for a specific id? I was trying the xpath query

"customers/customer[@id=2]" but that doesn't work.

Thanks

"Manish Bafna" wrote:
Hi,
You can do it easily by using XMLDocument and xpath query.
Below link shows how to read xml file and also how to add nodes to it.
http://www.codeguru.com/csharp/cshar....php/c9427__1/
And below link shows how to update nodes in xml file:
http://www.dotnetspider.com/kb/Article2938.aspx.
Also i would suggest you to changes structure of your xml file to the
following:
<customers>
<customer id="1">
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
<customer id="2">
<email>te**@test.com</email>
</customer>
<customer id="3">
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
</customers>
If you are having trouble using xpath query to retreive all the email
addresses for a specific customer (id) then please do let me know
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Chris" wrote:
Hi,
I need to store customers and their emails in an XML file for quick lookup
in a small program. I am kind of a bit confused with this XML thing. Do I use
XML or this XSD Schema?

I came up with this

<customers>
<customer>
<id>1</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
<customer>
<id>2</id>
<email>te**@test.com</email>
</customer>
<customer>
<id>3</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
</customers>

Is this useable? If yes, where do I get information on reading and writing
to XML? I couldn't find any information either on searching, ex if I want to
get all the email addresses for a specific customer (id).

Thanks
Jun 20 '07 #3
Hi,
Below code is working on my machine:
XmlDocument doc = new XmlDocument();
doc.Load("XMLFile1.xml");
XmlNodeList nodelist =
doc.SelectNodes("//customers/customer[@id='2']//email");

for(int i= 0;i<nodelist.Count;i++)
{
XmlNode node = nodelist[i];
MessageBox.Show(node.InnerText.ToString());
}
--
Hope this answers your question.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Chris" wrote:
Hi,
How do I find all emails for a specific id? I was trying the xpath query

"customers/customer[@id=2]" but that doesn't work.

Thanks

"Manish Bafna" wrote:
Hi,
You can do it easily by using XMLDocument and xpath query.
Below link shows how to read xml file and also how to add nodes to it.
http://www.codeguru.com/csharp/cshar....php/c9427__1/
And below link shows how to update nodes in xml file:
http://www.dotnetspider.com/kb/Article2938.aspx.
Also i would suggest you to changes structure of your xml file to the
following:
<customers>
<customer id="1">
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
<customer id="2">
<email>te**@test.com</email>
</customer>
<customer id="3">
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
</customers>
If you are having trouble using xpath query to retreive all the email
addresses for a specific customer (id) then please do let me know
--
Hope this helps.
Thanks and Regards.
Manish Bafna.
MCP and MCTS.

"Chris" wrote:
Hi,
I need to store customers and their emails in an XML file for quick lookup
in a small program. I am kind of a bit confused with this XML thing. Do I use
XML or this XSD Schema?
>
I came up with this
>
<customers>
<customer>
<id>1</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
<customer>
<id>2</id>
<email>te**@test.com</email>
</customer>
<customer>
<id>3</id>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
<email>te**@test.com</email>
</customer>
</customers>
>
Is this useable? If yes, where do I get information on reading and writing
to XML? I couldn't find any information either on searching, ex if I want to
get all the email addresses for a specific customer (id).
>
Thanks
Jun 20 '07 #4

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

Similar topics

2
1960
by: Gary Hampson | last post by:
I am trying to get the following: "pull the last, oh, 1000 topics, and rank that population by board posted-to and comments" Here is the query as written for MSSQL: SELECT dt.forum_id,...
1
1432
by: tread | last post by:
Objective: The primary table I loaded into MySql has 2.5 MM records: ID, Ticker, Date, Price; and all works well. My need is to write a QUERY to export outfile?) multiple text files. For example,...
20
2264
by: Yellowbird | last post by:
Anyone up for a challenge? If you have some time to spare and don't mind helping someone who is in the dark, I have some questions related to an IE-only page layout. Note that this page is part...
0
3336
by: Rolan | last post by:
I'm using Access 97 and need some assistance in sorting out a proper DSum expression, or maybe even DCount might be an alternative. I have tried numerous combinations, but with no apparent success....
4
6518
by: MLH | last post by:
I apologize in advance to forum readers noticing this somewhat redundant post. I fear that my Subject Heading was ill-chosen in earlier post I made on this topic. Am hoping that a clearer Subject...
4
1487
by: Ron Nolan | last post by:
Re: Access 2000 Has anyone been able to find information in the online help on the topic of "Common Dialog Control? If so, what did you type in your search to receive the information? I've been...
0
2010
by: Rolan | last post by:
I know what I want to do regarding the average cost for inventory, but need some assistance to sort out some of the details to finalize an inventory table and query. Essentially, the information is...
0
1255
by: Richard Mathis | last post by:
My problem is rather complicated (for me), so I'm going to post my problem here as well as what I've done so far to solve my problem. Any assistance would be appreciated. I originally posted this...
8
2216
by: mtalicagirl | last post by:
I am in need of assistance with an Access form. On my form I have a combo box and I would like the datasheet subform to populate with the data that is associated with my combo box selection. I know...
9
2741
by: OWeb | last post by:
Javascript and recursing subfolders assistance ------------------------- I have this script that is a free extra download from SlideShowPro. It's a great script but I feel it needs to be...
0
7111
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...
1
7031
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
5623
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,...
1
5042
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...
0
4702
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...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
412
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...

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.