473,320 Members | 1,535 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

Text to XML

I want to convert a text based protocol into XML, using C#, how do I do that
in the best maner ?
Can I use XSLT in any way ? or do I have to make an parser that converts the
file manually ?

An example of the text file:
BORN ANTAL AXLAR = 220

VARMGÅNG

TJUVBROMS

TEST EFTER TÅG !!
FELKODER
W00 T02

VARMGÅNGS MÄTVÄRDEN ANTAL AXLAR = 220 TÅGRIKTNING = U
LH097 023 029 030 029 026 031 017 030 022 029 033 027 032 027 025 020 033
034 029 024 031 028 027 024 031 027 020 024 033 037 031 019 027 026 022 022
032 024 022 019 032 026 024 029 029 028 029 024 032 031 028 027 032 031 021
026 031 029 023 027 030 032 025 022 025 031 027 024 039 032 023 025 032 029
023 027 029 038 025 028 028 027 024 024 034 025 020 029 028 037 025 028 035
031 023 025 024 026 023 023 030 032 025 021 039 033 022 027 035 026 020 028
031 029 023 024 035 027 027 024 027 026 024 022 033 027 027 025 030 029 030
028 032 028 027 025 030 024 034 026 025 023 024 025 028 029 023 029 036 032
022 027 030 029 028 025 028 027 022 024 035 027 034 028 033 023 022 025 030
025 028 027 032 028 022 027 030 026 020 029 029 028 025 024 016 017 013 012
018 012 011 015 016 012 014 013 019 012 013 013 014 011 011 013 036 027 032
029 028 022 024 024 023 017 017 021 032 026 018 025 LV097 028 026 027 033
039 027 031 032 024 025 027 023 037 026 028 023 031 028 025 022 030 028 023
024 028 025 025 026 032 029 024 021 033 022 020 022 034 023 022 021 028 029
026 023 030 027 025 026 033 028 023 019 032 028 023 026 030 023 024 032 030
026 022 024 028 022 020 029 036 032 022 021 038 025 026 025 032 033 026 027
030 020 027 025 038 024 024 029 027 027 019 027 035 021 025 023 034 026 028
026 032 030 028 018 035 031 027 026 029 031 022 024 029 022 023 020 028 031
023 037 028 022 024 020 032 024 021 031 031 028 029 020 032 025 029 022 032
024 032 026 025 025 026 020 031 026 024 026 034 030 022 022 033 026 021 024
034 023 022 020 034 029 025 035 034 021 027 027 032 029 024 024 023 027 028
028 025 023 023 021 032 032 023 023 013 013 008 012 014 013 008 010 013 012
011 010 016 013 009 016 014 010 008 011 046 032 027 027 029 025 024 019 028
010 024 010 033 020 021 022

TJUVBROMS MÄTVÄRDEN
LÅGNIVÅ HS = 047
LÅGNIVÅ VS = 047
ANTAL AXLAR HS = 220
ANTAL AXLAR VS = 220 TÅGRIKTNING = U
TH 002 002 001 001 002 002 002 002 002 002 002 002 001 002 002 001 001 001
001 001 001 001 001 001 002 001 001 001 002 002 002 002 001 001 001 002 001
001 001 001 001 001 002 001 001 001 002 001 001 001 002 002 001 001 001 001
002 001 002 001 002 001 002 001 001 001 002 001 001 001 002 002 001 001 001
001 002 001 002 001 001 002 001 002 001 001 002 001 001 001 002 001 001 001
001 002 001 001 002 001 001 001 001 001 001 001 001 001 001 001 001 001 002
001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 002 001
001 001 002 001 001 001 001 002 001 001 001 001 001 001 001 001 001 001 001
001 001 001 001 001 001 001 001 001 001 001 002 002 001 001 001 001 001 001
001 001 001 001 001 001 001 001 001 001 002 001 001 001 001 001 001 001 001
001 001 002 001 001 001 001 001 001 002 001 001 001 002 001 001 001 002 001
002 001 001 001 001 001 001 001 002 001 001 001 TV 001 001 002 001 002 001
003 002 002 002 003 001 003 003 002 001 001 001 003 003 001 001 001 002 003
002 001 001 001 003 003 002 001 001 002 003 002 001 001 001 002 002 002 001
001 002 003 002 001 001 001 002 002 001 001 001 003 002 001 001 002 002 002
001 001 001 003 002 001 001 002 003 001 001 001 001 003 001 001 001 003 003
002 001 002 003 002 001 001 001 002 002 001 001 003 003 001 001 002 003 001
001 001 002 002 001 002 001 002 001 001 001 003 002 001 001 002 003 001 001
001 002 002 001 001 002 003 001 001 001 003 002 001 001 003 003 001 001 002
003 001 001 002 002 001 001 002 003 001 001 002 002 001 001 002 003 001 001
001 003 002 001 002 002 002 001 001 002 002 001 001 001 002 001 002 001 002
001 001 001 002 001 001 001 002 002 002 002 002 001 002 003 001 001 002 003
001 001 002 002 001 001 002 002 001 001 003 002 001 002 002 002 001 001 002
001 002 002 001 001 <.
..
Nov 15 '05 #1
2 1543
Hi

TO the best of my knowledge, there is no direct parser
avaialble to convert text to xml. You have to write a
parser which reads input text and then parse and then
create a XML.

Ravikanth[MVP]

-----Original Message-----
I want to convert a text based protocol into XML, using C#, how do I do thatin the best maner ?
Can I use XSLT in any way ? or do I have to make an parser that converts thefile manually ?

An example of the text file:
BORN ANTAL AXLAR = 220

VARMGÅNG

TJUVBROMS

TEST EFTER TÅG !!
FELKODER
W00 T02

VARMGÅNGS MÄTVÄRDEN ANTAL AXLAR = 220 TÅGRIKTNING = U
LH097 023 029 030 029 026 031 017 030 022 029 033 027 032 027 025 020 033034 029 024 031 028 027 024 031 027 020 024 033 037 031 019 027 026 022 022032 024 022 019 032 026 024 029 029 028 029 024 032 031 028 027 032 031 021026 031 029 023 027 030 032 025 022 025 031 027 024 039 032 023 025 032 029023 027 029 038 025 028 028 027 024 024 034 025 020 029 028 037 025 028 035031 023 025 024 026 023 023 030 032 025 021 039 033 022 027 035 026 020 028031 029 023 024 035 027 027 024 027 026 024 022 033 027 027 025 030 029 030028 032 028 027 025 030 024 034 026 025 023 024 025 028 029 023 029 036 032022 027 030 029 028 025 028 027 022 024 035 027 034 028 033 023 022 025 030025 028 027 032 028 022 027 030 026 020 029 029 028 025 024 016 017 013 012018 012 011 015 016 012 014 013 019 012 013 013 014 011 011 013 036 027 032029 028 022 024 024 023 017 017 021 032 026 018 025 LV097 028 026 027 033039 027 031 032 024 025 027 023 037 026 028 023 031 028 025 022 030 028 023024 028 025 025 026 032 029 024 021 033 022 020 022 034 023 022 021 028 029026 023 030 027 025 026 033 028 023 019 032 028 023 026 030 023 024 032 030026 022 024 028 022 020 029 036 032 022 021 038 025 026 025 032 033 026 027030 020 027 025 038 024 024 029 027 027 019 027 035 021 025 023 034 026 028026 032 030 028 018 035 031 027 026 029 031 022 024 029 022 023 020 028 031023 037 028 022 024 020 032 024 021 031 031 028 029 020 032 025 029 022 032024 032 026 025 025 026 020 031 026 024 026 034 030 022 022 033 026 021 024034 023 022 020 034 029 025 035 034 021 027 027 032 029 024 024 023 027 028028 025 023 023 021 032 032 023 023 013 013 008 012 014 013 008 010 013 012011 010 016 013 009 016 014 010 008 011 046 032 027 027 029 025 024 019 028010 024 010 033 020 021 022

TJUVBROMS MÄTVÄRDEN
LÅGNIVÅ HS = 047
LÅGNIVÅ VS = 047
ANTAL AXLAR HS = 220
ANTAL AXLAR VS = 220 TÅGRIKTNING = U
TH 002 002 001 001 002 002 002 002 002 002 002 002 001 002 002 001 001 001001 001 001 001 001 001 002 001 001 001 002 002 002 002 001 001 001 002 001001 001 001 001 001 002 001 001 001 002 001 001 001 002 002 001 001 001 001002 001 002 001 002 001 002 001 001 001 002 001 001 001 002 002 001 001 001001 002 001 002 001 001 002 001 002 001 001 002 001 001 001 002 001 001 001001 002 001 001 002 001 001 001 001 001 001 001 001 001 001 001 001 001 002001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 001 002 001001 001 002 001 001 001 001 002 001 001 001 001 001 001 001 001 001 001 001001 001 001 001 001 001 001 001 001 001 001 002 002 001 001 001 001 001 001001 001 001 001 001 001 001 001 001 001 002 001 001 001 001 001 001 001 001001 001 002 001 001 001 001 001 001 002 001 001 001 002 001 001 001 002 001002 001 001 001 001 001 001 001 002 001 001 001 TV 001 001 002 001 002 001003 002 002 002 003 001 003 003 002 001 001 001 003 003 001 001 001 002 003002 001 001 001 003 003 002 001 001 002 003 002 001 001 001 002 002 002 001001 002 003 002 001 001 001 002 002 001 001 001 003 002 001 001 002 002 002001 001 001 003 002 001 001 002 003 001 001 001 001 003 001 001 001 003 003002 001 002 003 002 001 001 001 002 002 001 001 003 003 001 001 002 003 001001 001 002 002 001 002 001 002 001 001 001 003 002 001 001 002 003 001 001001 002 002 001 001 002 003 001 001 001 003 002 001 001 003 003 001 001 002003 001 001 002 002 001 001 002 003 001 001 002 002 001 001 002 003 001 001001 003 002 001 002 002 002 001 001 002 002 001 001 001 002 001 002 001 002001 001 001 002 001 001 001 002 002 002 002 002 001 002 003 001 001 002 003001 001 002 002 001 001 002 002 001 001 003 002 001 002 002 002 001 001 002001 002 002 001 001 <.
..
.

Nov 15 '05 #2
"Mattias Thuresson" <mt*@home.se> wrote:
Can I use XSLT in any way ?
Only with extension functions. By default, XSLT only accepts XML input.
or do I have to make an parser that converts the file manually ?


Yes. Prepare yourself by doing an example document in XML. And unless you
need to work in Dotnet, I'd recommend a language with (even) better string
handling for this task. Python is a good alternative.

Gustaf

Nov 15 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: joes | last post by:
Hello there ! I rendering a PDF with XSLT using Xalan and FOP. I like to place in my article an image, so that the text is floating around the image. I tried several things but it didn't work so...
3
by: Xerxes | last post by:
Hi, I need help in setting up a page where the text wraps around an image. Right now, I am using table, with text in one <td> and the image in the adjacent <td>. The problem is when the text is...
2
by: Macsicarr | last post by:
Hi All Wonder if you could help me. I have created a CMS system that allows the user to enter text and pic 'tags' for their own About us page, eg text.... text.... text.... text.......
2
by: Jiri Palecek | last post by:
I have a question on web authoring (probably HTML+CSS). Is it somehow possible to put two words above each other inside a paragraph so the result would be valid and render at least in Mozilla? I...
4
by: Arif Çimen | last post by:
Hi to everybody, I have chnged a button text in design mode. But After compiling and executing the program the text of the button do not change to new value. Any Ideas? Thaks for helps.
3
by: jweinberg1975 | last post by:
I would like for users to be able to select from a small number of options that come from a little drop down menu which then closes. .....
3
by: bbepristis | last post by:
Hey all I have this code that reads from one text file writes to another unless im on a certian line then it writes the new data however it only seems to do about 40 lines then quits and I cant...
3
by: acecraig100 | last post by:
I am fairly new to Javascript. I have a form that users fill out to enter an animal to exhibit at a fair. Because we have no way of knowing, how many animals a user may enter, I created a table...
3
by: jonniethecodeprince | last post by:
Hi all, I have trouble getting an array of data stored in a separate javascript file i.e. a file called books.js into a table of data for a .xhtml file. There are 50 Records in this file....
10
by: bluemountain | last post by:
Hi there, Iam new to python forms and programming too I had a text file where i need to extract few words of data from the header(which is of 3 lines) and search for the keyword TEXT1, TEXT2,...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.