public XmlElement ToXml(XmlDocument document) { XmlElement serviceNode = document.CreateElement("idmef:Service", "http://iana.org/idmef"); serviceNode.SetAttribute("ident", ident); if (ip_version != null) { serviceNode.SetAttribute("ip_version", ip_version.ToString()); } if (iana_protocol_number != null) { serviceNode.SetAttribute("iana_protocol_number", iana_protocol_number.ToString()); } if (!string.IsNullOrEmpty(iana_protocol_name)) { serviceNode.SetAttribute("iana_protocol_name", iana_protocol_name); } if (!string.IsNullOrEmpty(name)) { XmlElement serviceSubNode = document.CreateElement("idmef:name", "http://iana.org/idmef"); XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "name", "http://iana.org/idmef"); subNode.Value = name; serviceSubNode.AppendChild(subNode); serviceNode.AppendChild(serviceSubNode); } if (port != null) { XmlElement serviceSubNode = document.CreateElement("idmef:port", "http://iana.org/idmef"); XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "port", "http://iana.org/idmef"); subNode.Value = port.ToString(); serviceSubNode.AppendChild(subNode); serviceNode.AppendChild(serviceSubNode); } if (portList != null) { serviceNode.AppendChild(portList.ToXml(document)); } if (!string.IsNullOrEmpty(protocol)) { XmlElement serviceSubNode = document.CreateElement("idmef:protocol", "http://iana.org/idmef"); XmlNode subNode = document.CreateNode(XmlNodeType.Text, "idmef", "protocol", "http://iana.org/idmef"); subNode.Value = protocol; serviceSubNode.AppendChild(subNode); serviceNode.AppendChild(serviceSubNode); } if (snmpService != null) { serviceNode.AppendChild(snmpService.ToXml(document)); } if (webService != null) { serviceNode.AppendChild(webService.ToXml(document)); } return(serviceNode); }