http://www.codeproject.com/KB/linq/xelementns.aspx

 

 

 string myxml =
            @"<root>
                <one xmlns:a='http://rediff.com'>
                    <a:oneone  sequenceId= '11' xmlns:b='http://yahoo.com'>
                        <b:id>1</b:id>
                        <b:name></b:name>
                    </a:oneone>
                    <a:twotwo xmlns:b='http://orkut.com'>
                        <b:id>1</b:id>
                        <b:name></b:name>
                    </a:twotwo>
                </one>
              </root>
";

          XNamespace nsr = "http://rediff.com";
          XNamespace nsy = "http://yahoo.com";
       
            XElement elem = XElement.Parse(myxml);   

            string t = elem.Element("one").Element(nsr + "oneone").Element(nsy + "id").Value;

           string sequenceId = elem.Element("one").Element(nsr + "oneone").Attribute("sequenceId").Value;


           XDocument doc = new XDocument();
           doc = XDocument.Parse(myxml);

           XElement docElement = doc.Descendants(nsr + "oneone").FirstOrDefault();

           string t1 = docElement.Element(nsr + "oneone").Element(nsy + "id").Value;

           string sequenceId1 = docElement.Element(nsr + "oneone").Attribute("sequenceId").Value;

 

 

 

相关文章:

  • 2022-12-23
  • 2021-10-14
  • 2021-08-29
  • 2022-12-23
  • 2022-12-23
  • 2022-02-08
  • 2021-12-19
  • 2021-09-13
猜你喜欢
  • 2021-08-02
  • 2021-06-09
  • 2022-01-17
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2021-07-05
相关资源
相似解决方案