Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > XML > XML
Password Reminder
Register
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
XML General XML discussions.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the XML section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Display Modes
  #1 (permalink)  
Old October 10th, 2017, 09:23 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2017
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question XML file open in Notepad in correct format like xml format

Hi Guys,

We have a requirement to download the internal table data as XML file.

I am generating a XML file (welcome.xml) through PHP. The PHP code is as -

Code:
<?php  
$xmlString = '<?xml version="1.0" encoding="UTF-8"?>
    <urlset 
	xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
	xmlns:image="http://www.google.com/schemas/sitemap-image/1.1" 
	xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd" 
	xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
        <url>
            <loc>http://www.codexworld.com</loc>
            <lastmod>2016-07-04T07:46:18+00:00</lastmod>
            <changefreq>always</changefreq>
            <priority>1.00</priority>
        </url>
    </urlset>';

$dom = new DOMDocument;
$dom->preserveWhiteSpace = FALSE;
$dom->loadXML($xmlString);
$dom->formatOutput = TRUE;
//Save XML as a file
$dom->save('test/welcome.xml');

//View XML document

echo $dom->saveXml();

?>
Able to download the XML file in correct format, but when opened in NOTEPAD we are getting the complete tags of the XML in a single line.

We need the notepad file also to look like the format of the XML file when opened.

Please answer is there any solution for this (XML file should be in XML format when opened in Notepad). It should be done without using any XML Editor (XML formatting tool).

I tell you for your information that we are using Linux server and the code is lying inside Linux server. Also we don't want to use any XML Editor (XML formatting tool).


Please reply as soon as possible.

Thanks in advance.

Harish Pathak
Reply With Quote
  #2 (permalink)  
Old October 10th, 2017, 10:57 AM
mhkay's Avatar
Wrox Author
Points: 18,277, Level: 58
Points: 18,277, Level: 58 Points: 18,277, Level: 58 Points: 18,277, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,933
Thanks: 0
Thanked 282 Times in 277 Posts
Default

Notepad is probably the only piece of software left on the planet that requires Windows line endings and doesn't recognize Unix line endings.

XML parsers will accept either, so it sounds as if you want to generate an XML file using Windows line endings (that is, CRLF).

Your standard XML serialization library under PHP probably isn't going to do that, so you'll probably need to post-process the output by globally changing LF (x0A) to CRLF (x0Dx0A).
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #3 (permalink)  
Old October 11th, 2017, 03:54 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2017
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question changing LF to CRLF

Hi,

----------------------------------------------------------------------
so you'll probably need to post-process the output by globally changing LF (x0A) to CRLF (x0Dx0A).
----------------------------------------------------------------------

Thanks for your reply.

Please tell me how to change globally LF to CRLF. Please describe. Please give an example. I am not finding this solution in google.com.

Waiting for your response.

Thanks in advance.

Harish Pathak
Reply With Quote
  #4 (permalink)  
Old October 11th, 2017, 05:30 AM
mhkay's Avatar
Wrox Author
Points: 18,277, Level: 58
Points: 18,277, Level: 58 Points: 18,277, Level: 58 Points: 18,277, Level: 58
Activity: 100%
Activity: 100% Activity: 100% Activity: 100%
 
Join Date: Apr 2004
Location: Reading, Berks, United Kingdom.
Posts: 4,933
Thanks: 0
Thanked 282 Times in 277 Posts
Default

I'm happy to help you with technical XML problems but not with basic programming tasks.
__________________
Michael Kay
http://www.saxonica.com/
Author, XSLT 2.0 and XPath 2.0 Programmer\'s Reference
Reply With Quote
  #5 (permalink)  
Old October 11th, 2017, 06:25 AM
Registered User
Points: 12, Level: 1
Points: 12, Level: 1 Points: 12, Level: 1 Points: 12, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Oct 2017
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Question how to change globally LF to CRLF

Hi All,

Anybody please help me and tell me how to change globally LF (x0A) to CRLF (x0Dx0A).

Anybody have any idea about this please let me know.

Thanks in advance.

Harish Pathak
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Sending xml format through email, format issue!!! abhishekkashyap27 ASP.NET 2.0 Professional 0 December 14th, 2010 07:35 AM
Problem with date format in XML and XML Schema nelly78 XML 3 October 23rd, 2009 10:43 AM
Creating XML doc ; writing string(xml format) into KamalRaturi XML 5 May 28th, 2008 06:51 AM
How to export the data to XML file format? mbshankar Pro VB 6 2 April 3rd, 2007 01:22 PM
How Open CAD format file in C#? tomxu C# 0 August 25th, 2005 07:01 AM



All times are GMT -4. The time now is 09:12 PM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.