473,828 Members | 3,215 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

php5, tidy and xml cleaning problem

Hello,

I am using tidy to clean up an xml file, but my problem is that it
replaces newlines with normal whitespaces.
Still worse is that if i retrieve text from the xml file it contains all
whitespaces tidy inserted to nicely render the file.
The xml files are generated and retrieved with an DomDocument.
preserveWhitesp ace is false.

At the time i am solving the problem with some regexps and string
replacements, but this way i have to think of all the weird
possibilities and i am sure i will forget one or two ;-)

So this is how my xml gets saved:

$xml = $dom->saveXML();

// Specify configuration
$config = array(
'indent' => true,
'input-xml' => true,
'output-xml' => true,
'wrap' => 200);

// Tidy
$tidy = new tidy;
$tidy->parseString($x ml, $config, "utf8");
$tidy->cleanRepair( );
// write to the file
file_put_conten ts($path, (string)$tidy);

and how i load it:
$dom = new DomDocument();
$dom->preserveWhiteS pace = false;
$dom->load($this->path);
The End of a long post

Greetings
Jul 17 '05 #1
0 3328

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

Similar topics

1
2152
by: Mike Gifford | last post by:
Hello Folks, I'm trying to get tidy set up on a pretty standard fedora core 1 server. Looks pretty simple from here: http://ca3.php.net/manual/en/ref.tidy.php Should just have to go: pear -v install tidy However, it won't work unless you have the following up and running on
5
3401
by: Andrzej Adam Filip | last post by:
Could you post some recommendation/advices which options should be used when using tidy to beautify xhtml ? It seems that "wrapped" xhtml produced by standards settings is not "liked" by some search engines . e.g. tidy inserted line breaks in attributes after opening " .....<a href=" http://example.com/"> ...
2
1516
by: Kyndig | last post by:
This is 'weird'. I'm trying to port my project to php5 so I can get tidy support in php , and its stripping out my CSS _after_ I do a page reload and each page after that. The first page visit once the webserver is started outputs correctly. Every page visit after that strips my css. *boggle* restart webserver and visit page: Example from the source of one of my pages: restart webserver and visit page:
40
5625
by: VK | last post by:
Hi, After the response on my request from W3C I'm still unclear about Tidy vs. Validator discrepansies. That started with <IFRAME> issue, but there is more as I know. Anyway, this very basic HTML page: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Strict//EN" "http://www.w3.org/TR/html401/strict.dtd"> <html> <head>
8
4725
by: bruce | last post by:
hi... never used perl, but i have an issue trying to resolve some html that appears to be "dirty/malformed" regarding the overall structure. in researching validators, i came across the beautifulsoup app and wanted to know if anybody could give me pros/cons of the app as it relates to any of the other validation apps... the issue i'm facing involves parsing some websites, so i'm trying to extract information based on the DOM/XPath...
0
1886
by: BG Mahesh | last post by:
hi I have installed Tidy on Fedore Core 4.0 using RPM. I have a very simple script that uses tidy, ------------tidy.php------------------ <html>a html document</html> <? $html = ob_get_clean(); // Specify configuration
9
2342
by: Ragnar | last post by:
Hi I have one question regarding Tidy (http://tidy.sourceforge.net). My source XML-file has got a lot of unclosed <BR>-tags. Which command do I need (in my tidy config-file) to close it <BR/and make valid XML out of it? regards Rag.
2
3023
by: xio | last post by:
Hi, I have a bunch of files with PHP code. These files were written by multiple developers with different coding styles and is just so painful to read them. Could you recommend any tool I could use to clean up PHP code - something like "HTML Tidy for PHP" Thanks,
0
1147
by: Karl Groves | last post by:
I created a quick function I can call to clean up stuff input into forms with tidy. The problem I'm having at the moment is that everything within the 'src' attribute of <imgand within the 'href' attribute of <ais being stripped to only "/". So, for example: "<img src="/images/foo.gif">" is being changed to "<img src="/">" Any idea what's causing this? Here's the function. Nothing special, really.
0
10749
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10467
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10507
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9294
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7731
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6936
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5612
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5769
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3950
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.