Page 1 of 1

how to read text file as xml?

Posted: Thu Mar 25, 2010 10:06 pm
by ontario23
hi..I am a beginner
I want to know that how to read text file as xml?

Re: how to read text file as xml?

Posted: Fri Mar 26, 2010 11:30 am
by adrian
Hello,

You want to import a text file in XML?
To be able to import a text file it must have a separator between fields: comma, semicolon, tab or space.

You can do this in Oxygen from File -> Import -> Text file...

Let me know if I misunderstood.

Regards,
Adrian

Re: how to read text file as xml?

Posted: Fri Mar 26, 2010 12:53 pm
by ontario23
thanks

Re: how to read text file as xml?

Posted: Sat Nov 12, 2016 9:07 am
by balmerhevi
using LINQ is the simplest way...

StringBuilder result = new StringBuilder();
foreach (XElement level1Element in XElement.Load(@"D:\product.xml").Elements("Brand"))
{
result.AppendLine(level1Element.Attribute("name").Value);
foreach (XElement level2Element in level1Element.Elements("product"))
{
result.AppendLine(" " + level2Element.Attribute("name").Value);
}
}

Full SOurce...Read XML

Hevi