Parsing XML with Namespaces C#

前端 未结 1 675
谎友^
谎友^ 2021-01-22 08:40

I have been working on parsing this XML data all day. It seems like my problem is namespaces. I thought a had a glimmer of hope with my last website http://www.codeproject.com/A

1条回答
  •  广开言路
    2021-01-22 09:15

    Firstly: element name is Height and not Heigth.

    You can use this code to get Height value:

    var doc = XDocument.Load(path);
    
    XNamespace ns2 = "http://mws.amazonservices.com/schema/Products/2011-10-01/default.xsd";
    
    
    string val = doc.Document.Descendants(ns2 + "ItemDimensions")
        .FirstOrDefault().Element(ns2 + "Height").Value;
    
    Console.WriteLine(val);
    

    0 讨论(0)
提交回复
热议问题