473,224 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,224 software developers and data experts.

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.
preserveWhitespace 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($xml, $config, "utf8");
$tidy->cleanRepair();
// write to the file
file_put_contents($path, (string)$tidy);

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

Greetings
Jul 17 '05 #1
0 3294

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

Similar topics

1
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...
5
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...
2
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...
40
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...
8
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...
0
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 =...
9
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...
2
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...
0
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'...
1
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
0
by: veera ravala | last post by:
ServiceNow is a powerful cloud-based platform that offers a wide range of services to help organizations manage their workflows, operations, and IT services more efficiently. At its core, ServiceNow...
0
by: VivesProcSPL | last post by:
Obviously, one of the original purposes of SQL is to make data query processing easy. The language uses many English-like terms and syntax in an effort to make it easy to learn, particularly for...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 3 Jan 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). For other local times, please check World Time Buddy In...
0
by: jianzs | last post by:
Introduction Cloud-native applications are conventionally identified as those designed and nurtured on cloud infrastructure. Such applications, rooted in cloud technologies, skillfully benefit from...
0
by: mar23 | last post by:
Here's the situation. I have a form called frmDiceInventory with subform called subfrmDice. The subform's control source is linked to a query called qryDiceInventory. I've been trying to pick up the...
2
by: jimatqsi | last post by:
The boss wants the word "CONFIDENTIAL" overlaying certain reports. He wants it large, slanted across the page, on every page, very light gray, outlined letters, not block letters. I thought Word Art...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 7 Feb 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:30 (7.30PM). In this month's session, the creator of the excellent VBE...
0
by: MeoLessi9 | last post by:
I have VirtualBox installed on Windows 11 and now I would like to install Kali on a virtual machine. However, on the official website, I see two options: "Installer images" and "Virtual machines"....

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.