프로그램 자료/ASP.NET

ASP.NET XML String 값을 XML 값으로 파싱하기

motolies 2014. 6. 2. 09:25


Code Hehind 에서 쿼리를 날려 받은 XML 데이터

등을 HTML 과 같이 사용할 때 System.Xml.XmlDocument 와 함께 사용해서 하나씩 값을 뽑아보았다.




<table>

<%


System.Xml.XmlDocument XmlDoc = new System.Xml.XmlDocument();

XmlDoc.Load(new System.IO.StringReader(b.PRDLIST));

 

System.Xml.XmlNodeList xnList = XmlDoc.SelectNodes("/PRDS/PRD");

foreach (System.Xml.XmlNode xn in xnList)

{

    string Status = xn["Status"].InnerText;

    switch (Status)

    {

        case "N": Status = "Normal"; break;

        default: Status = "정보없음"; break;

    }

%>

          <tr style='vertical-align: top;'>

          <td>

              <p><%=Status %></p>
          </
td>

          </tr>

<%

}

%>

      </table>