Connecting Tech Pros Worldwide Forums | Help | Site Map

Line Feed XML File

Nader Shahin
Guest
 
Posts: n/a
#1: Nov 12 '05
I am using SqlXmlCommandType component to generate an XML file in a VB.net
Console Application. Everything ran perfect except one thing. I need to know
if there is anyway to make this XML file Line feed file. In other words, I
need to put each tag in one line instead of mixing them up.

Do I have to create an XSL file to do this transformation, or there is
another way on the .net framework to do it?

Pascal Schmitt
Guest
 
Posts: n/a
#2: Nov 12 '05

re: Line Feed XML File


Nader Shahin wrote:[color=blue]
> I am using SqlXmlCommandType component to generate an XML file in a VB.net
> Console Application. Everything ran perfect except one thing. I need to know
> if there is anyway to make this XML file Line feed file. In other words, I
> need to put each tag in one line instead of mixing them up.[/color]

Why do you need this? Every compilant XML parser shouldn't have any
problems with even all XML in one line.
[color=blue]
>
> Do I have to create an XSL file to do this transformation, or there is
> another way on the .net framework to do it?[/color]

The simplest way I know is inheriting a custom class from XmlTextWriter
and overwrite the Write.. Methods to add an '\n' to every written token.
(for example in public override WriteEndElement(){
base.WriteEndElement(); ...Write('\n'); })

Maybe indentation can also help you? It is not exactly what you
described but...

--
Pascal Schmitt
Nader Shahin
Guest
 
Posts: n/a
#3: Nov 12 '05

re: Line Feed XML File


I know that Every XML parser doesn't have any problems with this, but it's
required in my project.

I know that i can do it by XmlTextWriter but i don't need to write one by one.
This is why i used "ExecuteToStream" so i don't need to worry about each
element.

So I was thinking if i can create an XSL transformer i can solve this
problem but i am not sure if this is the right way or i can find something in
the .net can help.

"Pascal Schmitt" wrote:
[color=blue]
> Nader Shahin wrote:[color=green]
> > I am using SqlXmlCommandType component to generate an XML file in a VB.net
> > Console Application. Everything ran perfect except one thing. I need to know
> > if there is anyway to make this XML file Line feed file. In other words, I
> > need to put each tag in one line instead of mixing them up.[/color]
>
> Why do you need this? Every compilant XML parser shouldn't have any
> problems with even all XML in one line.
>[color=green]
> >
> > Do I have to create an XSL file to do this transformation, or there is
> > another way on the .net framework to do it?[/color]
>
> The simplest way I know is inheriting a custom class from XmlTextWriter
> and overwrite the Write.. Methods to add an '\n' to every written token.
> (for example in public override WriteEndElement(){
> base.WriteEndElement(); ...Write('\n'); })
>
> Maybe indentation can also help you? It is not exactly what you
> described but...
>
> --
> Pascal Schmitt
>[/color]
gsaby2002@yahoo.com
Guest
 
Posts: n/a
#4: Nov 12 '05

re: Line Feed XML File


Yes, there are ways you can use .Net Methods to format your XML file or use XSl for your specific problem. If you are using an XMLTextWriter to generate the XML just set the Formatting property of the writer to Formatting.Indented

MyXmlTextWriter.Formatting = Formatting.Indented;

you can also set the number of characters per indentation by setting the indentation property to an int value corresponding to the number of characters. I think this will take care of your needs. We can discuss more on several other possibilities if you have any other specific queries on this.



************************************************** ********************
Sent via Fuzzy Software @ http://www.fuzzysoftware.com/
Comprehensive, categorised, searchable collection of links to ASP & ASP.NET resources...
Closed Thread