Get child Node of another Node, given node name

前端 未结 4 1262
再見小時候
再見小時候 2021-02-11 15:21

I have an XML like this:


  
    1
    Declaration of Human Rights         


        
4条回答
  •  囚心锁ツ
    2021-02-11 16:06

    //xn=list of parent nodes......                
    foreach (XmlNode xn in xnList)
    {                                           
        foreach (XmlNode child in xn.ChildNodes) 
        {
            if (child.Name.Equals("name")) 
            {
                name = child.InnerText; 
            }
            if (child.Name.Equals("age"))
            {
                age = child.InnerText; 
            }
        }
    }
    

提交回复
热议问题