c# read XML file not correctly formatted

后端 未结 3 1795
情话喂你
情话喂你 2021-01-22 07:58

I have to read an XML file, that has no root element, to extract contained data. The XML has many elements like these:


  

        
3条回答
  •  佛祖请我去吃肉
    2021-01-22 08:30

    I found a way to solve my problem, I gave up to read it as an XML and I read it as a StreamReader, looking for the text I want to read, so I don't have to fight against the XML format

    using (StreamReader strReader = File.OpenText(path))
                {
                    while (!strReader.EndOfStream)
                    {
                        string line = strReader.ReadLine();
                        if (line.Contains("")) {
                            line = strReader.ReadLine();
                            string data_ = getTagText(line);
                            string channelName_ = getTagText( strReader.ReadLine());
                            string sql_ = getTagText( strReader.ReadLine());
                            string idHotel_ = getTagText(strReader.ReadLine());
                            string type_ = getTagText(strReader.ReadLine());
    
    
                        }
    
    
                    }
                }
    

提交回复
热议问题