public void InsertElementTest() { var doc = new XmlDoc("<root/>"); var node = doc.InsertBefore(doc.CreateXmlDeclaration("1.0", "utf-8", ""), doc.DocumentElement); Assert.IsNotNull(node); var firstElement = doc.AddElementText(doc.DocumentElement, "first", ""); Assert.IsNotNull(firstElement); var second = doc.InsertElementBefore(firstElement, "second", ""); Assert.IsNotNull(second); }
public void AddElementTest() { var doc = new XmlDoc("<root/>"); var child = doc.AddElementText(doc.DocumentElement, "child", "child element text"); Assert.IsNotNull(child); var grandChild = doc.AddElementText(child, "grandChild", "child of child element text"); Assert.IsNotNull(grandChild); Console.WriteLine("Child.OuterXml : " + child.OuterXml); Console.WriteLine("Child.InnerXml : " + child.InnerXml); Console.WriteLine("Child.InnerText : " + child.InnerText); }
public static void ValidateChartXml(IChart chart) { var xmlText = chart.GetDataXml(true); if(IsDebugEnabled) { log.Debug("Chart Xml:"); log.Debug(xmlText); } var doc = new XmlDoc(xmlText); Assert.IsTrue(doc.IsValidDocument); }
public void AddNodeTest() { var doc = new XmlDoc("<root/>"); Assert.IsTrue(XmlTool.IsValidDocument(doc)); var element = doc.AddNode(doc.DocumentElement, XmlNodeType.Element, "Element", "ElementText"); Assert.IsNotNull(element); Assert.AreEqual("Element", element.Name); // XmlComment 노드는 var comment = doc.AddNode(element, XmlNodeType.Comment, string.Empty, "CommentsText"); Assert.AreEqual("#comment", comment.Name); Assert.AreEqual("CommentsText", comment.Value); }
public void AddXmlAttributeTest() { var doc = new XmlDoc("<root/>"); var idAttr = doc.AddAttribute(doc.DocumentElement, "id", "root id"); var nameAttr = doc.AddAttribute(doc.DocumentElement, "name", "root name"); Assert.AreEqual("id", idAttr.Name); Assert.AreEqual("root id", idAttr.Value); Assert.AreEqual("name", nameAttr.Name); Assert.AreEqual("root name", nameAttr.Value); idAttr = doc.GetAttributeNode(doc.DocumentElement, "id"); nameAttr = doc.GetAttributeNode(doc.DocumentElement, "name"); Assert.AreEqual("id", idAttr.Name); Assert.AreEqual("root id", idAttr.Value); Assert.AreEqual("name", nameAttr.Name); Assert.AreEqual("root name", nameAttr.Value); }
/// <summary> /// RealWeb XML HTTP 통신 모듈 설정이다. /// </summary> /// <param name="uri">서버 URI</param> /// <param name="document">요청용 RclXmlDocument</param> /// <param name="isAsync">비동기 통신 여부</param> /// <param name="timeoutMilliseconds">통신 제한시간 (default : System.Threading.Timeout.Infinite)</param> /// <param name="userId"></param> /// <param name="password"></param> /// <returns>응답 XmlDocument</returns> public static XmlDoc Send(string uri, XmlDoc document, bool isAsync = false, int timeoutMilliseconds = System.Threading.Timeout.Infinite, string userId = null, string password = null) { uri.ShouldNotBeWhiteSpace("uri"); if(IsDebugEnabled) log.Debug("Send xml document... uri=[{0}], isAsync=[{1}], timeout=[{2}], userId=[{3}], password=[{4}], document=[{5}]", uri, isAsync, timeoutMilliseconds, userId, password, document); Guard.Assert(document.IsValidDocument(), @"document object is not valid document."); var xmlHttp = new XmlHttpClient(uri, isAsync, timeoutMilliseconds, userId, password); var xdoc = xmlHttp.Send(document); if(IsDebugEnabled) log.Debug("Send xml... uri=[{0}], result=[{1}]", uri, xdoc.Text); return xdoc; }
public void CreateXmlDocument() { var doc = new XmlDoc(); Assert.IsFalse(doc.IsValidDocument); }
public void CreateXmlDocumentByString() { var doc = new XmlDoc("<root/>"); Assert.IsTrue(doc.IsValidDocument); Console.WriteLine(doc.InnerXml); }
public static void ValidateChartXmlByReflection(IChart chart) { var xmlText = ChartExtensions.BuildChartXml(chart, true); if(IsDebugEnabled) log.Debug(xmlText); var doc = new XmlDoc(xmlText); Assert.IsTrue(doc.IsValidDocument); }
/// <summary> /// Posting request xml document to server /// </summary> /// <param name="requestDoc"></param> /// <returns></returns> public XmlDoc Send(XmlDoc requestDoc) { requestDoc.ShouldNotBeNull("requestDoc"); Guard.Assert(requestDoc.IsValidDocument(), @"requestDoc is not valid xml document."); XmlDoc responseDoc = null; try { responseDoc = (XmlDoc)PostXml(requestDoc); } catch(Exception ex) { if(responseDoc.IsValidDocument()) responseDoc.AddElement(responseDoc.Root, "ERROR", ex.Message); else { if(log.IsErrorEnabled) log.ErrorException("Error occurred in Send() method.", ex); throw; } } return responseDoc; }