how to read text file as xml?

Questions about XML that are not covered by the other forums should go here.
ontario23
Posts: 2
Joined: Thu Mar 25, 2010 9:18 pm
Contact:

how to read text file as xml?

Post by ontario23 »

hi..I am a beginner
I want to know that how to read text file as xml?
adrian
Posts: 2879
Joined: Tue May 17, 2005 4:01 pm

Re: how to read text file as xml?

Post 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
Adrian Buza
<oXygen/> XML Editor, Schema Editor and XSLT Editor/Debugger
http://www.oxygenxml.com
ontario23
Posts: 2
Joined: Thu Mar 25, 2010 9:18 pm
Contact:

Re: how to read text file as xml?

Post by ontario23 »

thanks
balmerhevi
Posts: 1
Joined: Sat Nov 12, 2016 9:05 am

Re: how to read text file as xml?

Post 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
Post Reply