rxraza
asked on
cannot append to the XML node.
Hi folks:
I am having the following error out of the third line.
System.InvalidOperationExc eption: The current node cannot contain other nodes.
XmlNode appt = CreateParameter("XML_DATA" ,"",false, "");
appt.AppendChild(CreateNod e("APPOINT _REQUEST") );
appt.FirstChild.AppendChil d(CreateNo de("FAMILY NO",family No,false)) ;
Can't I just append to the first child of the node that I already appended. Any ideas????
Following are the definition of other functions used:
protected XmlElement CreateNode(string elementName)
{
XmlElement node = doc.CreateElement(elementN ame);
return node;
}
protected XmlElement CreateNode(string elementName,string elementValue,bool isCDATA)
{
XmlElement node = doc.CreateElement(elementN ame);
// create a CDATA elemetn in here
if (isCDATA )
{
XmlCDataSection cDATA = doc.CreateCDataSection(ele mentValue) ;
node.AppendChild(cDATA);
}
else
node.InnerText = elementValue;
return node;
}
protected XmlElement CreateParameter(string name,string data,bool isCDATA,string type)
{
XmlElement node = doc.CreateElement("PARAM") ;
XmlAttribute attribute = doc.CreateAttribute("NAME" );
attribute.InnerText = name;
node.Attributes.Append(att ribute);
attribute = doc.CreateAttribute("TYPE" );
attribute.InnerText = type;
node.Attributes.Append(att ribute);
if (isCDATA)
{
XmlCDataSection cDATA = doc.CreateCDataSection(dat a);
node.AppendChild(cDATA);
}
else
{
node.InnerText = data;
}
return node;
}
I am having the following error out of the third line.
System.InvalidOperationExc
XmlNode appt = CreateParameter("XML_DATA"
appt.AppendChild(CreateNod
appt.FirstChild.AppendChil
Can't I just append to the first child of the node that I already appended. Any ideas????
Following are the definition of other functions used:
protected XmlElement CreateNode(string elementName)
{
XmlElement node = doc.CreateElement(elementN
return node;
}
protected XmlElement CreateNode(string elementName,string elementValue,bool isCDATA)
{
XmlElement node = doc.CreateElement(elementN
// create a CDATA elemetn in here
if (isCDATA )
{
XmlCDataSection cDATA = doc.CreateCDataSection(ele
node.AppendChild(cDATA);
}
else
node.InnerText = elementValue;
return node;
}
protected XmlElement CreateParameter(string name,string data,bool isCDATA,string type)
{
XmlElement node = doc.CreateElement("PARAM")
XmlAttribute attribute = doc.CreateAttribute("NAME"
attribute.InnerText = name;
node.Attributes.Append(att
attribute = doc.CreateAttribute("TYPE"
attribute.InnerText = type;
node.Attributes.Append(att
if (isCDATA)
{
XmlCDataSection cDATA = doc.CreateCDataSection(dat
node.AppendChild(cDATA);
}
else
{
node.InnerText = data;
}
return node;
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.