|
-
August 14th, 2008, 03:13 AM
#1
[RESOLVED] Write xml content to a notepad using xsl
Hi all,
I want to write some data into a notepad from a xml file using xsl. How can I do that. Can anyone of you give me a guide to do it.
Thanks
-
August 14th, 2008, 06:28 AM
#2
Re: Write xml content to a notepad using xsl
What do you mean? Do you want to write the xsl to a file that can be opened in notepad (i.e. a file with a .txt extension)? Do you want to display the xsl text in an opened notepad?
-
August 14th, 2008, 08:18 PM
#3
Re: Write xml content to a notepad using xsl
Ok, I'll explain it more.
I have an xml file. I want to get some data from that xml file and write into a notepad. That means a file with an extension .txt. I want to define font type and size. So I want to use an xsl file to do this. How can I do that? Hope it's clear now.
-
August 14th, 2008, 09:05 PM
#4
Re: Write xml content to a notepad using xsl
Okay, you need to write a text file that can be opened with notepad.
The problem is since you want to store text with formatting, you aren't going to be able to do that with a .txt file format. Notepad allows you to change the font; however, it's the font used in notepad and this font doesn't get stored in the .txt file.
The .rtf format allows you to store formatted text. Notepad can't open this type of file, but wordpad can.
Actually notepad can open this type of file, but it shows up with the rtf formatting:
{\rtf1\ansi\ansicpg1252\deff0\deflang1033{\fonttbl{\f0\fswiss\fcharset0 Arial;}}
{\*\generator Msftedit 5.41.21.2500;}\viewkind4\uc1\pard\b\f0\fs20 This is a test.\b0\par
}
-
August 14th, 2008, 09:12 PM
#5
Re: Write xml content to a notepad using xsl
Is it not possible to define the font type in xsl file? I mean can't we define the output format/style of the xml to notepad in xsl file?
I found an example that, xml convert into an excel file. There also font type define in the xsl file.
Here is the link
-
August 14th, 2008, 10:40 PM
#6
Re: Write xml content to a notepad using xsl
Sure you can get xsl to format it however you like.
But a .txt file isn't going to display formatted text. It will only display plain text.
If you need to include formatting with the text, you'll need to store it in a format other than .txt.
-
August 14th, 2008, 10:45 PM
#7
Re: Write xml content to a notepad using xsl
Ok sir, at the time just forget the format. I just want to write some element values to a .txt file. Can you tel me how to do it. Please, any example really helpful sir.
-
August 14th, 2008, 10:52 PM
#8
Re: Write xml content to a notepad using xsl
See reply #3 in this post: Using TextWriter.
-
August 14th, 2008, 11:18 PM
#9
Re: Write xml content to a notepad using xsl
Thanks. Before adding to a text file I try to read the xml file correctly. Here is the structure of my xml.
Code:
<Messages>
<Chat Tag="no" MG="no">
<Sender>Jhon</Sender>
<color>#000001</color>
hi
</Chat>
<Chat Tag="no" MG="no">
<Sender>Tim</Sender>
<color>#000001</color>
hello
</Chat>
</Messages>
There are lots of elements, but the required data on Messages element. At the end, output should be like this.
Code:
Jhon:
hi
Tim:
hello
First I try to find the Message element.
Code:
XmlTextReader reader = new XmlTextReader("temp.xml");
while (reader.Read())
{
switch (reader.NodeType)
{
case XmlNodeType.Element: // The node is an Element
if (reader.Name == "Messages")
{
// Here I'm stuck with
}
}
}
I'm stuck with that how to move in each chat element and collect data. Please help me.
-
August 15th, 2008, 12:35 AM
#10
Re: Write xml content to a notepad using xsl
Ok, at the end I got the way to do it. Now it's working fine. Thanks for all comments.
-
August 15th, 2008, 01:30 AM
#11
Re: [RESOLVED] Write xml content to a notepad using xsl
Glad to hear it's working.
-
August 15th, 2008, 01:31 AM
#12
Re: [RESOLVED] Write xml content to a notepad using xsl
Ya, I bit change the xml file format first. So simply I can deal with elements.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|