XML
-
C# XML 파일 읽기/쓰기닷넷/C# 2023. 3. 28. 16:42
C#에서 XML 파일을 읽고 쓰는 방법은 여러 가지가 있습니다. 다음은 각 방법과 코드 예시입니다. 1. XmlReader를 사용하여 XML 파일을 읽고 쓰는 방법 1) XML 파일 읽기 (1) XmlReader를 사용하여 XML 파일을 읽습니다. using System.Xml; XmlReader xmlReader = XmlReader.Create("file.xml"); (2) XmlReader에서 필요한 데이터를 읽습니다. while (xmlReader.Read()) { if (xmlReader.NodeType == XmlNodeType.Element && xmlReader.Name == "node") { // Do something with the data } } (3) XMLReader를 닫습니다...
-
C# 웹통신 요청 및 응답 (WebRequest POST, WebResponse) (ContentType: application/x-www-form-urlencoded)닷넷/C# 2018. 11. 15. 10:08
private void HTTPPost(){ string sParam = "sParam1=value1&sParam2=value2"; string sUrl = "http://abc/web"; // 서버 접속 WebRequest webRequest = WebRequest.Create(sUrl); webRequest.Method = "POST"; // 데이터 전송 byte[] bytearry = Encoding.UTF8.GetBytes(sParam); webRequest.ContentType = "application/x-www-form-urlencoded"; webRequest.ContentLength = bytearry.Length; Stream stream = webRequest.GetRequestStr..