Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 6 of 6
  1. #1
    Regular Coder
    Join Date
    Jan 2004
    Posts
    185
    Thanks
    2
    Thanked 1 Time in 1 Post

    hiding tags with include or readfile, without losing them

    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.

    Code:
    <?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>
    <? 
    } 
    ?>

  • #2
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    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

  • #3
    Regular Coder
    Join Date
    Jan 2004
    Posts
    185
    Thanks
    2
    Thanked 1 Time in 1 Post
    thanks for the reply... node tags are the author-defined and arbitrarily named tags that separate and structure xml data

    Code:
    <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.

  • #4
    Mega-ultimate member
    Join Date
    Jun 2002
    Location
    Winona, MN - The land of 10,000 lakes
    Posts
    1,855
    Thanks
    1
    Thanked 45 Times in 42 Posts
    Quote Originally Posted by subhailc
    thanks for the reply... node tags are the author-defined and arbitrarily named tags that separate and structure xml data

    Code:
    <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"!

  • #5
    Regular Coder
    Join Date
    Jun 2002
    Posts
    905
    Thanks
    23
    Thanked 5 Times in 5 Posts
    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?

  • #6
    Senior Coder
    Join Date
    Aug 2003
    Location
    One step ahead of you.
    Posts
    2,815
    Thanks
    0
    Thanked 3 Times in 3 Posts
    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.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •