728x90
📌 xml 파일 경로 넣어주기
namespace Query.OSPP
{
public class QueryPath {
public string xmlQueryPath()
{
string _path = Path.Combine(HttpContext.Current.Server.MapPath("").Replace("\\Model.Service", ""), "Query.OSPP");
return _path;
}
}
HttpContext.Current.Server.MapPath("") 로 현재 파일의 경로 추출 뒤에 자꾸 \Model.Service가 붙어서 Replace로 없애버림
📌 xml 파일 불러오기
- 참조에 해당 프로젝트 추가하기
- using문에 프로젝트 추가
public List<형이름> Get메서드이름 (string Uid)
{
// path 가져오기
QueryPath queryPath = new QueryPath();
string tmp = queryPath.xmlQueryPath();
// xml 연결
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(Path.Combine(tmp, "가상주소1", "xml파일명.xml"));
// xml에서 값 가져오기
XmlNode ctg_node = xmlDoc.SelectSingleNode("Node태그이름");
XmlNode name_node = xmlDoc.SelectSingleNode("Node태그이름/Query(가져올태그이름)");
📌 불러올 xml파일 작성하기
<?xml version="1.0" encoding="utf-8" ?>
<Node태그이름>
<Query>
쿼리문
</Query>
</Node태그이름>
💌 Reference
https://error999.tistory.com/5
C# - Xml파일 제어, Xml파싱
Xml파일이나 텍스트가 있을 경우 Xml내부에 있는 값을 가져오기 위해서는 다음과 같은 방법을 쓸 수 있습니다. Xml파일 확인케이스 - Xml 속성값 가져오기 - 하위노드 리스트 가져오기 - 노드의 값
error999.tistory.com
728x90
'C# > C# WPF 실무' 카테고리의 다른 글
[C# WPF] XML 에서 자식 노드 명과 자식 노드 값 가져오기 (0) | 2023.09.11 |
---|---|
[C# WPF] Oracle DB연동하기 (2) | 2023.09.07 |
[C# WPF][DevExpress] band를 이용한 GridControl 의 Header 및 Cell (row) 모두 가운데 정렬하기 (0) | 2023.08.16 |
[C# WPF][DevExpress] Band GridControl 에 DataTable 형식으로 Binding 하기 (0) | 2023.08.16 |
[C# WPF][DevExpress] Bands GridControl 열 셀 색깔 넣기 (0) | 2023.08.16 |