Невероятно но факт: не могу читать XML - C#

Узнай цену своей работы

Формулировка задачи:

Имеем XML:
<?xml version="1.0" encoding="utf-8"?>
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">urn:exportOrgRegistry</Action>
    <h:ISRequestHeader xmlns="http://dom.gosuslugi.ru/schema/integration/base/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:h="http://dom.gosuslugi.ru/schema/integration/base/">
      <Date>2018-03-16T11:33:15.1206654+07:00</Date>
      <MessageGUID>d1500d01-0e24-4fe4-a554-0506f6952a05</MessageGUID>
    </h:ISRequestHeader>
  </s:Header>
  <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <exportOrgRegistryRequest Id="signed-data-container" p5:version="10.0.2.1" xmlns:p5="http://dom.gosuslugi.ru/schema/integration/base/" xmlns="http://dom.gosuslugi.ru/schema/integration/organizations-registry-common/">
      <SearchCriteria>
        <OGRN xmlns="http://dom.gosuslugi.ru/schema/integration/organizations-base/">1145543013880</OGRN>
      </SearchCriteria>
    </exportOrgRegistryRequest>
  </s:Body>
</s:Envelope>
var XML = XDocument.Parse(xmlString);
var Request = XML.Root?.Element(@"Header")?.Element(@"Action")?.Value;
Не работает. Нужно указывать неймспейсы. И вот тут беда. Все примеры из сети не работают у меня.... :-(
var ns = XML.Root.Name.Namespace;
XML.Root.Element(ns + "Header")
XML.Root.Element(new XName("Header", "http://schemas.xmlsoap.org/soap/envelope/"))
Сработало только после тотальной зачистки ВСЕХ неймспесов в XML. Не могу разобраться как читать из XML с неймспейсами... Помогите пожалуйста.

Решение задачи: «Невероятно но факт: не могу читать XML»

textual
Листинг программы
var XML = XDocument.Parse(xmlString);
var Request = XML.Root?.nonsElement(@"Header")?.nonsElement(@"Action")?.Value;
var Responce = XML.Root.nonsElement(@"Header")?.nonsElement(@"ResultHeader")?.nonsElement(@"MessageGUID")?.Value;

Оцени полезность:

5   голосов , оценка 3.6 из 5
Похожие ответы