posted by 방랑군 2009. 9. 23. 14:48


  <unity>

    <NAME>황승재</NAME>

    <ADDRESS AD1="서울시" AD2="염창동" AD3="동아3차아파트" AD4="307동 1101호" />

    <HP>016-647-0678</HP>

  </unity>


ADDRESS 의 Attribute 값 가져오는 법


section.SelectSingleNode("ADDRESS").Attributes["AD1"].Value

"서울시"


/// 더미..

section.SelectSingleNode("ADDRESS").OuterXml

"<ADDRESS AD1=\"서울시\" AD2=\"염창동\" AD3=\"동아3차아파트\" AD4=\"307동 1101호\" />"

section.SelectSingleNode("ADDRESS").Attributes["AD1"].OuterXml

"AD1=\"서울시\""




ADDRESS 의 Element 값 가져오는 법

section.SelectSingleNode("NAME").InnerText; 

"황승재"



IConfigurationSectionHandler  에서 값 할당

#region IConfigurationSectionHandler 멤버


public object Create(object parent, object configContext, System.Xml.XmlNode section)

{

    //throw new NotImplementedException();


    UserInfo obj = new UserInfo();


    

    obj._NAME    = section.SelectSingleNode("NAME").InnerText; // section 이용하여 config 값 넣는다.  

    obj._ADDRESS = doc.SelectSingleNode("unity/ADDRESS").Attributes["AD1"].Value;

    obj._HP      = section.SelectSingleNode("HP").InnerText; // section 이용하여 config 값 넣는다.

    return obj;

}


#endregion