missing one attribute when creating a XML node - InfoPath Dev
in

InfoPath Dev

missing one attribute when creating a XML node

Last post 04-21-2009 09:29 PM by Jimmy. 1 replies.
Page 1 of 1 (2 items)
Sort Posts: Previous Next
  • 04-21-2009 09:13 PM

    missing one attribute when creating a XML node

    Hi there,

    I am using the following code to creata a xml node with 5 attributes but I discover the last attribute is always missing. Can anyone help me to find out what is the problem? 

    ================================================================================= 

       XmlDocument doc = new XmlDocument();
       XmlNode node = doc.CreateElement("WORKER_ALLOCATION_OpenEpisode", NamespaceManager.LookupNamespace("d"));
       XmlAttribute attr;

       attr = doc.CreateAttribute("OpenEpisodeID");   
       node.Attributes.Append(attr);
       
       attr = doc.CreateAttribute("WorkerAllocationID");
       node.Attributes.Append(attr);
       
       attr = doc.CreateAttribute("EpisodeNumber");
       attr.Value = episodeNumber;
       node.Attributes.Append(attr);

       attr = doc.CreateAttribute("T2Team");
       attr.Value = T2Team;
       node.Attributes.Append(attr);

       doc.CreateAttribute("PrimaryClinician");
       attr.Value = primaryClinician;
       node.Attributes.Append(attr);   
       
       doc.AppendChild(node);

    ====================================================

    The xml content of variable doc is as follows and the last attribute, named "PrimaryClinician", is missing.

     <WORKER_ALLOCATION_OpenEpisode OpenEpisodeID="" WorkerAllocationID="" EpisodeNumber="E001" T2Team="Don Murrphys" xmlns="http://schemas.microsoft.com/office/infopath/2003/ado/dataFields" />  

    Filed under:
  • 04-21-2009 09:29 PM In reply to

    Re: missing one attribute when creating a XML node

    You're missing "attr = " in the fourth line from the end.

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
Page 1 of 1 (2 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.