...

View Full Version : hiding tags with include or readfile, without losing them



subhailc
09-30-2004, 02:56 PM
hi. i'm using the following to edit an xml sheet. works fine, but i'd like to hide the node tags without actually removing them (i need to preserve the tag syntax).

i'm guessing there's an easy way, but not sure if that'd be through php, xml or even html - any direction would be helpful.



<?php
$filename = "cmadata.xml";
if($submit && $string)
{
$textfile= fopen($filename,'w+');
fputs($textfile, $string);
fclose($textfile);
}
else {
?>
<html>
<body>
<form method=post action="<? echo $PHP_SELF; ?>" ?>
<textarea name=string><?php include 'cmadata.xml'; ?></textarea>
<input type=submit name=submit></form>
</body>
</html>
<?
}
?>

sir pannels
09-30-2004, 03:00 PM
Hey :)

...I'm not sure if I follow 100% here.. by mode tags what exatly do you mean?

Either you mean the html <tags> or the file ext.. if its the file ext and you just wanna hide it - have you looked into mod rewrite funtiions? php.net is good for that...

Or html tags.. why would you need to hide them? they shouldnt display if they are formatted correct.

Maybe this is an XML issue, inwhich case.. you are best off ignoring me ;)

Good luck!!

Sir P

subhailc
09-30-2004, 03:23 PM
thanks for the reply... node tags are the author-defined and arbitrarily named tags that separate and structure xml data



<root node>
<name>jim</name>
<age>22</age>
<vd>syphillis</vd>
<breakfastcereal>captain crunch</breakfastcereal>
</root node>


when displayed in html via data binding, the tags are hidden - like you could bind all the <name> and <age> nodes to <td>'s and get a little 2 column table that provided the content within those tags.

i'm loading the xml sheet into a textarea with php's include function, editting it as needed, and saving it back to the server (also with php). this is all fine and dandy, but it's rendering the node tags as well in the text area (this isn't really a problem but i/whoever edits has to just edit 'around' them, and the whole point of doing it this way was so other people could work besides me :/) - and i'm aware of some php functions that'll kill the tags (i think strip_tags or htmlspclchars or something), but i can't kill the tags completely since im saving it directly, so i'd just like to hide them for the time they're displayed in the textarea.

bcarl314
09-30-2004, 05:51 PM
thanks for the reply... node tags are the author-defined and arbitrarily named tags that separate and structure xml data



<root node>
<name>jim</name>
<age>22</age>
<vd>syphillis</vd>
<breakfastcereal>captain crunch</breakfastcereal>
</root node>




Hmm, lets look at this example:

Name - Normal enough
Age - Yep another common bit-o-info
vd - What the?
breakfastcereal - Huh?

Yep, I'd say that's very "arbitrarily named"! :D

sir pannels
10-01-2004, 12:40 PM
Ok I follow now.

Are the node tags a fixed place in the file?
If so you can instead of including the file why not open the file and stick the contents in a var... do not put the entire file into the var... start it after or before the lines for your node tags. If you node tags are in the middle somewhere of the file then make 2 vars.. the first will contain all information in the file before the node tags.. ignor that bit then start the second var which will include all of the rest of the file.

With me?

marek_mar
10-01-2004, 02:38 PM
You could write an XML parser and disply the info in textboxes and convert it back to XML.
This way you do it I don't see the need for XML unless you parse it when you show the contents somewhere else.



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum