Click here to Skip to main content
16,004,974 members
Home / Discussions / C#
   

C#

 
GeneralXML Bulk Loader (SQLXML 3.0) Pin
exhaulted6-Jan-05 3:43
exhaulted6-Jan-05 3:43 
GeneralRe: XML Bulk Loader (SQLXML 3.0) Pin
perlmunger6-Jan-05 5:37
perlmunger6-Jan-05 5:37 
GeneralInfragistics UltraCalendarInfo control Pin
eliea6-Jan-05 1:45
eliea6-Jan-05 1:45 
GeneralRe: Infragistics UltraCalendarInfo control Pin
Nick Parker6-Jan-05 6:50
protectorNick Parker6-Jan-05 6:50 
Generalmodifying xml field data's using c# Pin
dhol6-Jan-05 1:42
dhol6-Jan-05 1:42 
GeneralRe: modifying xml field data's using c# Pin
perlmunger6-Jan-05 5:43
perlmunger6-Jan-05 5:43 
GeneralRe: modifying xml field data's using c# Pin
dhol6-Jan-05 16:38
dhol6-Jan-05 16:38 
GeneralRe: modifying xml field data's using c# Pin
perlmunger7-Jan-05 6:27
perlmunger7-Jan-05 6:27 
I think I understand a little bit better now, however, I still need some clarification. Here's what I think you're saying--You have a schema file and two XML files. While you are iterating through the fields in the schema, you want to look up the current field in the second xml file and copy the data to a field in the first xml file. Is that correct?

I'll assume it is for a moment. There is a method on the XmlElement object called SelectSingleNode. This method uses XPath to allow you to select a single node based on a query criteria somewhat similar to a SQL query. Here is an example from the Microsoft site:

using System;
using System.IO;
using System.Xml;

public class Sample
{
public static void Main()
{

XmlDocument doc = new XmlDocument();
doc.Load("booksort.xml");

//Create an XmlNamespaceManager for resolving namespaces.
XmlNamespaceManager nsmgr = new XmlNamespaceManager(doc.NameTable);
nsmgr.AddNamespace("bk", "urn:samples");

//Select the book node with the matching attribute value.
XmlNode book;
XmlElement root = doc.DocumentElement;
book = root.SelectSingleNode("descendant::book[@bk:ISBN='1-861001-57-6']", nsmgr);

Console.WriteLine(book.OuterXml);

}
}

And here is the related XML file:

<?xml version="1.0"?>
<!-- A fragment of a book store inventory database -->
<bookstore xmlns:bk="urn:samples">
<book genre="novel" publicationdate="1997" bk:ISBN="1-861001-57-8">
<title>Pride And Prejudice</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
<price>24.95</price>
</book>
<book genre="novel" publicationdate="1992" bk:ISBN="1-861002-30-1">
<title>The Handmaid's Tale</title>
<author>
<first-name>Margaret</first-name>
<last-name>Atwood</last-name>
</author>
<price>29.95</price>
</book>
<book genre="novel" publicationdate="1991" bk:ISBN="1-861001-57-6">
<title>Emma</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
<price>19.95</price>
</book>
<book genre="novel" publicationdate="1982" bk:ISBN="1-861001-45-3">
<title>Sense and Sensibility</title>
<author>
<first-name>Jane</first-name>
<last-name>Austen</last-name>
</author>
<price>19.95</price>
</book>
</bookstore>

I'm not sure if this is going to help you or not, but if I understand your correctly, then you should be able to get the node you're looking for using this method on the first XML file. The key is that you will have to now what you're looking for.

Let me know if I've missed the boat completely here and if so, just clarify what you are trying to do.

Best Regards.

-Matt

p.s. Here is a link to the documentation I got the code from http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfSystemXmlXmlNodeClassSelectSingleNodeTopic.asp .

------------------------------------------

The 3 great virtues of a programmer:
Laziness, Impatience, and Hubris.
--Larry Wall
GeneralRe: modifying xml field data's using c# Pin
dhol7-Jan-05 17:05
dhol7-Jan-05 17:05 
GeneralMethod return Value Pin
webhay5-Jan-05 23:43
webhay5-Jan-05 23:43 
GeneralRe: Method return Value Pin
Stefan Troschuetz5-Jan-05 23:59
Stefan Troschuetz5-Jan-05 23:59 
GeneralRe: Method return Value Pin
haimlz6-Jan-05 1:02
haimlz6-Jan-05 1:02 
GeneralRe: Method return Value Pin
Salil Khedkar6-Jan-05 1:07
Salil Khedkar6-Jan-05 1:07 
GeneralXmlDocument Write problems and Add Identation Help! Pin
Chua Wen Ching5-Jan-05 23:40
Chua Wen Ching5-Jan-05 23:40 
GeneralRe: XmlDocument Write problems and Add Identation Help! Pin
Stanimir_Stoyanov6-Jan-05 0:07
Stanimir_Stoyanov6-Jan-05 0:07 
GeneralRe: XmlDocument Write problems and Add Identation Help! Pin
J4amieC6-Jan-05 3:03
J4amieC6-Jan-05 3:03 
GeneralRe: XmlDocument Write problems and Add Identation Help! Pin
Chua Wen Ching6-Jan-05 13:34
Chua Wen Ching6-Jan-05 13:34 
GeneralList View items - exporting and importing data Pin
Stanimir_Stoyanov5-Jan-05 22:43
Stanimir_Stoyanov5-Jan-05 22:43 
GeneralRe: List View items - exporting and importing data Pin
Patric_J6-Jan-05 10:55
Patric_J6-Jan-05 10:55 
GeneralPrint without preview in C# Pin
gbess5-Jan-05 22:39
gbess5-Jan-05 22:39 
Generalimage screensaver with mem probs Pin
Steven_T5-Jan-05 20:41
Steven_T5-Jan-05 20:41 
GeneralRe: image screensaver with mem probs Pin
perlmunger6-Jan-05 6:11
perlmunger6-Jan-05 6:11 
GeneralRe: image screensaver with mem probs Pin
Steven_T6-Jan-05 21:21
Steven_T6-Jan-05 21:21 
GeneralRe: image screensaver with mem probs Pin
Steven_T6-Jan-05 23:23
Steven_T6-Jan-05 23:23 
QuestionHow to get explorer like (custom?) controls. Pin
E_NoName5-Jan-05 16:30
E_NoName5-Jan-05 16:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.