0

I have an XML document with ISO-8859-1 encoding. I can load the XML with XDOCUMENT, but i can't storage a specific node. Can somebody help me with this? The xml:

<?xml version="1.0" ?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Body>
    <TERMEKADATOutput xmlns="http://xmlns.oracle.com/orawsv/PUPHAX/PUPHAXWS">
      <RETURN>
        <OBJTERMEKADAT>              
          <TTT>210037069</TTT>
          <TK>OGYI-T-04617/05</TK>             
        </OBJTERMEKADAT>
      </RETURN>
    </TERMEKADATOutput>
  </soap:Body>
</soap:Envelope>

And the code:

XDocument xmlDoc = null;    
        using (StreamReader oReader = new StreamReader(@"C:\Users\maruzsama\source\repos\EPPuphax\EPPuphax\asd.xml", Encoding.GetEncoding("ISO-8859-1")))
        {
            xmlDoc = XDocument.Load(oReader); //this working fine
            var result = from q in xmlDoc.Descendants("OBJTERMEKADAT")
                         select new
                         {
                             asd = q.Element("TTT").Value
                         };
            Console.ReadKey();
        }

I need the data from the TTT node (210037069)

1 Answer 1

0

Try following changes :

XDocument xmlDoc = null;    
        using (StreamReader oReader = new StreamReader(@"C:\Users\maruzsama\source\repos\EPPuphax\EPPuphax\asd.xml", Encoding.GetEncoding("ISO-8859-1")))
        {
            xmlDoc = XDocument.Load(oReader); //this working fine
            XElement TERMEKADATOutput = xmlDoc.Descendants().Where(x => x.Name.LocalName == "TERMEKADATOutput").First();
            XNamespace ns = TERMEKADATOutput.GetDefaultNamespace();
            var result = from q in  TERMEKADATOutput.Descendants(ns + "OBJTERMEKADAT")
                         select new
                         {
                             asd = q.Element(ns + "TTT").Value
                         };
            Console.ReadKey();
        }
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.