c# - Merging XML files using external entities in Visual Studio 2008 -


I have some XML data in three files (Database. XML, Participants.XML, and ConditionToken.exml). I am trying to put participants and condition tokens in the database file to use external entities, but when I run this code ...

  string xmlPath = Environment.CurrentDirectory + @ "\ Data \ Database.xml"; Acceleration database = expansion.load (XMLPath);  

... my participants have no participants or condition tokens (HasElements property is incorrect for "database"). There should be two child elements, I do not get any errors / warnings in Visual Studio (2008), and live schema verification looks great, but when I run my code, something is not very right.

Can anyone tell me what I am doing wrong?

I have pasted three XML files below.

Thanks a lot!

- Dan

Database.xml

   

ConditionToken XML

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; ConditionTokens & gt; & Lt; ConditionToken & gt; & Lt; ID & gt; 1 & lt; / Id & gt; & Lt; Token & gt; LargeToSmall & lt; / Token & gt; & Lt; / ConditionToken & gt; & Lt; ConditionToken & gt; & Lt; ID & gt; 2 & lt; / Id & gt; & Lt; Token & gt; SmallToLarge & lt; / Token & gt; & Lt; / ConditionToken & gt; & Lt; / ConditionTokens & gt;  

participants.xml

  & lt ;? Xml version = "1.0" encoding = "UTF-8"? & Gt; & Lt; Participants & gt; & Lt; Partner & gt; & Lt; ID & gt; 1 & lt; / Id & gt; & Lt; ConditionTokenId & gt; 1 & lt; / ConditionTokenId> & Lt; / Partner & gt; & Lt; Partner & gt; & Lt; ID & gt; 2 & lt; / Id & gt; & Lt; ConditionTokenId & gt; 2 & lt; / ConditionTokenId> & Lt; / Partner & gt; & Lt; / Participants & gt; <3>  

I used the XmlDocument class to load 3 documents Would have done

  XmlDocument xmlDatabase = new XmlDocument (); XmlDatabase.Load (DatabasePath); XmlDocument xmlTokens = New XmlDocument (); XmlTokens.Load (tokensPath); XmlDocument xmlParticipants = New XmlDocument (); XmlParticipants.Load (participantsPath);  

Then attach each other using the ImportNode and AppendNode ...

  xmlDatabase.FirstChild.AppendNode (xmlDatabase.ImportNode (xmlTokens.FirstChild) , truth); XmlDatabase.FirstChild.AppendNode (xmlDatabase.ImportNode (xmlParticipants.FirstChild), True);  

Should it do too much (or use the xpeth selector instead of using first chal?)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -