Convert a structured text files to xml with LINQ

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
Hi,<br/><br/>Im very new to LINQ and I was hoping to get some ideas or help to convert a C-like tagged text file to XML format. Here is what I need to accomplish:<br/><br/>I have text files that contain similar information to the below:<br/><br/>:ASCII: File<br/>( <br/> ( machineName GateKeeper ) <br/> ( officeLocation Seattle ) <br/> ( isLapTop false) <br/> ( files <br/> ( file <br/> ( fileType text ) <br/> ( fileName foo.txt ) <br/> ( path C: ) <br/> ( size 10Mb ) ) ) <br/>)
I need it to be in this xml format:
<fileInfo><br/> <machineName>GateKeeper</machineName><br/> <officeLocation>Seattle</officeLocation><br/> <isLapTop>false</isLapTop><br/> <files><br/> <file><br/> <fileType>text</fileType><br/> <fileName>foo.txt</fileName><br/> <path>C:</path><br/> <size>10Mb</size><br/> </file><br/> </files><br/></fileInfo><br/><br/>I could accomplish this task by laoding the file in a text reader and manipulate each line, but I wondering if anybody can help me or give me ideas on how to do that with LINQ.<br/><br/>Thanks in advance,<br/>Danny

View the full article
 
Back
Top