Click here to Skip to main content
15,886,362 members
Home / Discussions / C#
   

C#

 
GeneralRe: Compare picturebox.image with image from a resource file Pin
dizzyJ19-Apr-10 3:07
dizzyJ19-Apr-10 3:07 
AnswerRe: Compare picturebox.image with image from a resource file Pin
sadiq_arbaoui17-Jan-11 23:07
sadiq_arbaoui17-Jan-11 23:07 
QuestionManipulate XML Pin
NarVish18-Apr-10 23:32
NarVish18-Apr-10 23:32 
AnswerRe: Manipulate XML Pin
NavnathKale19-Apr-10 0:00
NavnathKale19-Apr-10 0:00 
GeneralRe: Manipulate XML Pin
NarVish19-Apr-10 1:13
NarVish19-Apr-10 1:13 
GeneralRe: Manipulate XML Pin
NavnathKale19-Apr-10 2:08
NavnathKale19-Apr-10 2:08 
GeneralRe: Manipulate XML Pin
NarVish19-Apr-10 3:11
NarVish19-Apr-10 3:11 
GeneralRe: Manipulate XML Pin
NarVish19-Apr-10 19:13
NarVish19-Apr-10 19:13 
In the below xml, I would like to add this element
<StudentClass ref="F_GAMES" />
after
<StudentClass ref="F_STRENGTH" />
where student id=101.
The below code is
Please correct the below code.. its wrongly updating the xml. Thanks in advance..

<?xml version="1.0"?>
  <StudentRecords>       
      <Student ID="100">
    <StudentClass id="XA" name="XA" >
      <StudentClass ref="F_HEIGHT" />
      <StudentClass ref="F_WEIGHT" />
      <StudentClass ref="F_STRENGTH" />
      <StudentClass ref="F_LIBRARY" /> 
      <StudentClass ref="F_QUALIFIER" />
    </StudentClass>
  </Student>
  <Student ID="101">
    <StudentClass id="XB" name="XB" >
      <StudentClass ref="F_HEIGHT" />
      <StudentClass ref="F_WEIGHT" />
      <StudentClass ref="F_STRENGTH" />
      <StudentClass ref="F_LIBRARY" />     </StudentClass>
</Student> 
</StudentRecords>  

XmlDocument xmlDoc = new XmlDocument();            
            xmlDoc.Load(Application.StartupPath :-D  + "\\doc.xml");           
            string xpath = string.Format("/StudentRecords/Student");            
            XmlNodeList fieldNodes = xmlDoc.SelectNodes(xpath);            
            XmlNode studentNode = null;            
            XmlNode refNode = null;                        
            foreach (XmlNode node in fieldNodes)            
            {
                if (node.Attributes["ID"].Value == "101")    
                {
                    fieldNodes = xmlDoc.SelectNodes(xpath + "/StudentClass");
                    XmlNode node1 = fieldNodes.Item(0);
                    studentNode = node1;
                    refNode = node1.SelectSingleNode("StudentClass");
                    break;
                }
                       
            }            
            if (studentNode != null && refNode != null)            
            {
                XmlElement newcatalogentry = xmlDoc.CreateElement("StudentClass");
                XmlAttribute newcatalogattr = xmlDoc.CreateAttribute("ref");            
                newcatalogattr.Value = "F_NewCategory";                
                // Attach the attribute to the XML element                
                newcatalogentry.SetAttributeNode(newcatalogattr);                
                // New XML element inserted into the document                
                studentNode.InsertAfter(newcatalogentry, refNode);                
                string path = "C:\\test.xml";                                
                xmlDoc.Save(path);            
            }

GeneralRe: Manipulate XML Pin
NavnathKale19-Apr-10 21:48
NavnathKale19-Apr-10 21:48 
GeneralRe: Manipulate XML Pin
NarVish19-Apr-10 23:34
NarVish19-Apr-10 23:34 
GeneralRe: Manipulate XML Pin
NavnathKale20-Apr-10 0:58
NavnathKale20-Apr-10 0:58 
GeneralRe: Manipulate XML Pin
NarVish20-Apr-10 1:20
NarVish20-Apr-10 1:20 
GeneralRe: Manipulate XML Pin
NavnathKale20-Apr-10 1:21
NavnathKale20-Apr-10 1:21 
QuestionHow to put large text data (~20mb) into sql cs 3.5 database? Pin
Anindya Chatterjee18-Apr-10 21:42
Anindya Chatterjee18-Apr-10 21:42 
AnswerRe: How to put large text data (~20mb) into sql cs 3.5 database? Pin
Ashfield18-Apr-10 22:16
Ashfield18-Apr-10 22:16 
GeneralRe: How to put large text data (~20mb) into sql cs 3.5 database? Pin
Anindya Chatterjee18-Apr-10 22:28
Anindya Chatterjee18-Apr-10 22:28 
GeneralRe: How to put large text data (~20mb) into sql cs 3.5 database? Pin
Ashfield18-Apr-10 22:43
Ashfield18-Apr-10 22:43 
GeneralRe: How to put large text data (~20mb) into sql cs 3.5 database? Pin
Md. Marufuzzaman19-Apr-10 0:09
professionalMd. Marufuzzaman19-Apr-10 0:09 
GeneralRe: How to put large text data (~20mb) into sql cs 3.5 database? Pin
Anindya Chatterjee19-Apr-10 0:41
Anindya Chatterjee19-Apr-10 0:41 
QuestionMFC to C# HELP ? Pin
Nematjon Rahmanov18-Apr-10 20:16
Nematjon Rahmanov18-Apr-10 20:16 
AnswerRe: MFC to C# HELP ? Pin
Jimmanuel19-Apr-10 4:08
Jimmanuel19-Apr-10 4:08 
QuestionNetwork Scanning Pin
satsumatable18-Apr-10 19:39
satsumatable18-Apr-10 19:39 
Questiondeploying web service on windows 7 Pin
Ice_Freez0518-Apr-10 18:56
Ice_Freez0518-Apr-10 18:56 
AnswerRe: deploying web service on windows 7 Pin
Calla18-Apr-10 21:36
Calla18-Apr-10 21:36 
GeneralRe: deploying web service on windows 7 Pin
Ice_Freez0518-Apr-10 23:28
Ice_Freez0518-Apr-10 23:28 

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.