Discussion:
XML Document
Jim Wagner
2016-12-08 18:56:15 UTC
Permalink
Greetings NUG -

Trying to (re)learn how to create and parse XML documents and how to read/write to a file. One thing, that I don’t quite understand, is happening. It has to do with end-of-line in the saved file.

Now, I am fairly sure that this makes little difference in the conversion from a string into an XmlDocument, but the visual validation is painful with a single string, no line ending, no indenting. All of the examples I see, including the LR’s entry for XmlDocument, shows a single line per element, and nicely indented. Yet, when I view the generated xml file (in TextWrangler, which is set up to view xml files), its just a single, long line.

Is there something I can do, presumably in xml.ToString (btw, I cannot find any documentation on an xml method named “ToString”!) to add useful line endings?

Thanks
Jim

James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>




_______________________________________________

Xojo forum:

https://forum.xojo
vaughnsc .
2016-12-08 19:03:51 UTC
Permalink
Use Transform to 'pretty print' it with xslt. I have a text constant with
the snippet of xslt I've used for years, but I don't have it on the phone.
Googling 'xml pretty print' should point the way though.

Vaughn
Post by Jim Wagner
Greetings NUG -
Trying to (re)learn how to create and parse XML documents and how to
read/write to a file. One thing, that I don’t quite understand, is
happening. It has to do with end-of-line in the saved file.
Now, I am fairly sure that this makes little difference in the conversion
from a string into an XmlDocument, but the visual validation is painful
with a single string, no line ending, no indenting. All of the examples I
see, including the LR’s entry for XmlDocument, shows a single line per
element, and nicely indented. Yet, when I view the generated xml file (in
TextWrangler, which is set up to view xml files), its just a single, long
line.
Is there something I can do, presumably in xml.ToString (btw, I cannot
find any documentation on an xml method named “ToString”!) to add useful
line endings?
Thanks
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xojo f
Jim Wagner
2016-12-08 19:11:00 UTC
Permalink
Thanks

Jim

James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by vaughnsc .
Use Transform to 'pretty print' it with xslt. I have a text constant with
the snippet of xslt I've used for years, but I don't have it on the phone.
Googling 'xml pretty print' should point the way though.
Vaughn
Post by Jim Wagner
Greetings NUG -
Trying to (re)learn how to create and parse XML documents and how to
read/write to a file. One thing, that I don’t quite understand, is
happening. It has to do with end-of-line in the saved file.
Now, I am fairly sure that this makes little difference in the conversion
from a string into an XmlDocument, but the visual validation is painful
with a single string, no line ending, no indenting. All of the examples I
see, including the LR’s entry for XmlDocument, shows a single line per
element, and nicely indented. Yet, when I view the generated xml file (in
TextWrangler, which is set up to view xml files), its just a single, long
line.
Is there something I can do, presumably in xml.ToString (btw, I cannot
find any documentation on an xml method named “ToString”!) to add useful
line endings?
Thanks
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________

X
emile.a.schwarz
2016-12-08 19:35:02 UTC
Permalink
Hi James,

 

get an eye there:

 

https://forum.xojo.com/17131-xml-tostring-with-tab-and-return/0

 

and follow the path.

 

A .ToString can be sent to TextArea / saved to disk.

 

Enjoy,

 

Emile

 

 

 
Message du 08/12/16 19:59
De : "Jim Wagner"
A : "Nug"
Objet : XML Document
Greetings NUG - Trying to (re)learn how to create and parse XML documents and how to read/write to a file. One thing, that I don’t quite understand, is happening. It has to do with end-of-line in the saved file. Now, I am fairly sure that this makes little difference in the conversion from a string into an XmlDocument, but the visual validation is painful with a single string, no line ending, no indenting. All of the examples I see, including the LR’s entry for XmlDocument, shows a single line per element, and nicely indented. Yet, when I view the generated xml file (in TextWrangler, which is set up to view xml files), its just a single, long line. Is there something I can do, presumably in xml.ToString (btw, I cannot find any documentation on an xml method named “ToString”!) to add useful line endings? Thanks Jim James Wagner Oregon Research Electronics http://www.orelectronics.net _______________________________________________ Xojo forum: https://forum.xojo.com/
_______________________________________________

Xojo
Jim Wagner
2016-12-08 19:48:37 UTC
Permalink
Thanks, Emile -

For now, one of the on-lilne “pretty print” utilities is all I need. But, that is a very useful thread.

Jim

James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by emile.a.schwarz
Hi James,
https://forum.xojo.com/17131-xml-tostring-with-tab-and-return/0
and follow the path.
A .ToString can be sent to TextArea / saved to disk.
Enjoy,
Emile
Message du 08/12/16 19:59
De : "Jim Wagner"
A : "Nug"
Objet : XML Document
Greetings NUG - Trying to (re)learn how to create and parse XML documents and how to read/write to a file. One thing, that I don’t quite understand, is happening. It has to do with end-of-line in the saved file. Now, I am fairly sure that this makes little difference in the conversion from a string into an XmlDocument, but the visual validation is painful with a single string, no line ending, no indenting. All of the examples I see, including the LR’s entry for XmlDocument, shows a single line per element, and nicely indented. Yet, when I view the generated xml file (in TextWrangler, which is set up to view xml files), its just a single, long line. Is there something I can do, presumably in xml.ToString (btw, I cannot find any documentation on an xml method named “ToString”!) to add useful line endings? Thanks Jim James Wagner Oregon Research Electronics http://www.orelectronics.net _______________________________________________ Xojo forum: https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xojo forum:

https://forum.xojo.com
V S Cordero
2016-12-08 22:52:37 UTC
Permalink
Hi again, Jim
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:copy-of select="/" />
</xsl:template>
</xsl:transform>
I usually place this in a constant somewhere e.g. ‘kPrettyPrintXSL' and then:

dim pretty as string=myXmlDoc.Transform(kPrettyPrintXSL)

The ‘indent’ attribute forces line breaks in the result. I can then view the variable ‘pretty’ in the debugger or write it to disk with a textOutputStream.

Cheers,

Vaughn
Thanks, Emile -
For now, one of the on-lilne “pretty print” utilities is all I need. But, that is a very useful thread.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by emile.a.schwarz
Hi James,
https://forum.xojo.com/17131-xml-tostring-with-tab-and-return/0
and follow the path.
A .ToString can be sent to TextArea / saved to disk.
Enjoy,
Emile
Message du 08/12/16 19:59
De : "Jim Wagner"
A : "Nug"
Objet : XML Document
Greetings NUG - Trying to (re)learn how to create and parse XML documents and how to read/write to a file. One thing, that I don’t quite understand, is happening. It has to do with end-of-line in the saved file. Now, I am fairly sure that this makes little difference in the conversion from a string into an XmlDocument, but the visual validation is painful with a single string, no line ending, no indenting. All of the examples I see, including the LR’s entry for XmlDocument, shows a single line per element, and nicely indented. Yet, when I view the generated xml file (in TextWrangler, which is set up to view xml files), its just a single, long line. Is there something I can do, presumably in xml.ToString (btw, I cannot find any documentation on an xml method named “ToString”!) to add useful line endings? Thanks Jim James Wagner Oregon Research Electronics http://www.orelectronics.net _______________________________________________ Xojo forum: https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xojo forum:

https://forum.xojo
Jim Wagner
2016-12-08 23:07:44 UTC
Permalink
Thanks

Am I correct that the constant is a single string?

Jim

James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by V S Cordero
Hi again, Jim
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:copy-of select="/" />
</xsl:template>
</xsl:transform>
dim pretty as string=myXmlDoc.Transform(kPrettyPrintXSL)
The ‘indent’ attribute forces line breaks in the result. I can then view the variable ‘pretty’ in the debugger or write it to disk with a textOutputStream.
Cheers,
Vaughn
Thanks, Emile -
For now, one of the on-lilne “pretty print” utilities is all I need. But, that is a very useful thread.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by emile.a.schwarz
Hi James,
https://forum.xojo.com/17131-xml-tostring-with-tab-and-return/0
and follow the path.
A .ToString can be sent to TextArea / saved to disk.
Enjoy,
Emile
Message du 08/12/16 19:59
De : "Jim Wagner"
A : "Nug"
Objet : XML Document
Greetings NUG - Trying to (re)learn how to create and parse XML documents and how to read/write to a file. One thing, that I don’t quite understand, is happening. It has to do with end-of-line in the saved file. Now, I am fairly sure that this makes little difference in the conversion from a string into an XmlDocument, but the visual validation is painful with a single string, no line ending, no indenting. All of the examples I see, including the LR’s entry for XmlDocument, shows a single line per element, and nicely indented. Yet, when I view the generated xml file (in TextWrangler, which is set up to view xml files), its just a single, long line. Is there something I can do, presumably in xml.ToString (btw, I cannot find any documentation on an xml method named “ToString”!) to add useful line endings? Thanks Jim James Wagner Oregon Research Electronics http://www.orelectronics.net _______________________________________________ Xojo forum: https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xoj
Support
2016-12-08 23:12:00 UTC
Permalink
Yeah, its XML itself, so it works with/out breaks. A single string.

Cheers,

Vaughn
Post by Jim Wagner
Thanks
Am I correct that the constant is a single string?
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by V S Cordero
Hi again, Jim
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:copy-of select="/" />
</xsl:template>
</xsl:transform>
dim pretty as string=myXmlDoc.Transform(kPrettyPrintXSL)
The ‘indent’ attribute forces line breaks in the result. I can then view the variable ‘pretty’ in the debugger or write it to disk with a textOutputStream.
Cheers,
Vaughn
Thanks, Emile -
For now, one of the on-lilne “pretty print” utilities is all I need. But, that is a very useful thread.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by emile.a.schwarz
Hi James,
https://forum.xojo.com/17131-xml-tostring-with-tab-and-return/0
and follow the path.
A .ToString can be sent to TextArea / saved to disk.
Enjoy,
Emile
Message du 08/12/16 19:59
De : "Jim Wagner"
A : "Nug"
Objet : XML Document
Greetings NUG - Trying to (re)learn how to create and parse XML documents and how to read/write to a file. One thing, that I don’t quite understand, is happening. It has to do with end-of-line in the saved file. Now, I am fairly sure that this makes little difference in the conversion from a string into an XmlDocument, but the visual validation is painful with a single string, no line ending, no indenting. All of the examples I see, including the LR’s entry for XmlDocument, shows a single line per element, and nicely indented. Yet, when I view the generated xml file (in TextWrangler, which is set up to view xml files), its just a single, long line. Is there something I can do, presumably in xml.ToString (btw, I cannot find any documentation on an xml method named “ToString”!) to add useful line endings? Thanks Jim James Wagner Oregon Research Electronics http://www.orelectronics.net _______________________________________________ Xojo forum: https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xojo forum:

https://forum
Jim Wagner
2016-12-08 23:17:30 UTC
Permalink
Thanks

Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by Support
Yeah, its XML itself, so it works with/out breaks. A single string.
Cheers,
Vaughn
Post by Jim Wagner
Thanks
Am I correct that the constant is a single string?
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by V S Cordero
Hi again, Jim
<?xml version="1.0" encoding="UTF-8"?>
<xsl:transform version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="xml" indent="yes" />
<xsl:template match="/">
<xsl:copy-of select="/" />
</xsl:template>
</xsl:transform>
dim pretty as string=myXmlDoc.Transform(kPrettyPrintXSL)
The ‘indent’ attribute forces line breaks in the result. I can then view the variable ‘pretty’ in the debugger or write it to disk with a textOutputStream.
Cheers,
Vaughn
Thanks, Emile -
For now, one of the on-lilne “pretty print” utilities is all I need. But, that is a very useful thread.
Jim
James Wagner
Oregon Research Electronics
http://www.orelectronics.net <http://www.orelectronics.net/>
Post by emile.a.schwarz
Hi James,
https://forum.xojo.com/17131-xml-tostring-with-tab-and-return/0
and follow the path.
A .ToString can be sent to TextArea / saved to disk.
Enjoy,
Emile
Message du 08/12/16 19:59
De : "Jim Wagner"
A : "Nug"
Objet : XML Document
Greetings NUG - Trying to (re)learn how to create and parse XML documents and how to read/write to a file. One thing, that I don’t quite understand, is happening. It has to do with end-of-line in the saved file. Now, I am fairly sure that this makes little difference in the conversion from a string into an XmlDocument, but the visual validation is painful with a single string, no line ending, no indenting. All of the examples I see, including the LR’s entry for XmlDocument, shows a single line per element, and nicely indented. Yet, when I view the generated xml file (in TextWrangler, which is set up to view xml files), its just a single, long line. Is there something I can do, presumably in xml.ToString (btw, I cannot find any documentation on an xml method named “ToString”!) to add useful line endings? Thanks Jim James Wagner Oregon Research Electronics http://www.orelectronics.net _______________________________________________ Xojo forum: https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________
https://forum.xojo.com/
_______________________________________________

Xojo forum:

https://forum.x

Loading...