SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: XML formatting.

  1. #1
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    XML formatting.

    How do I format XML files to be user-friendly?

    Right now when I use SimpleXML, I get something like this

    HTML Code:
    <script><category>
    </category><title>
    </title></script>
    Here is what writes the childs.
    PHP Code:
    $script $xml->addChild('script');
    foreach (
    $clean as $k=>$v)
    {
        if (!
    in_array($k$ignore))
            
    $script->addChild($k$v);


  2. #2
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    What is the exact xml output you expect to see?

  3. #3
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by Cups View Post
    What is the exact xml output you expect to see?
    HTML Code:
    <library>
        <script>
            <title> 
                Foo Bar
            </title>
            <category>
                PHP
            </category>
        </script>
    </library>
    Something like this.

  4. #4
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    Right, I am guessing your question is about nicely indenting xml source code (not adding children or values)

    Did you look at the source code of the page?

    Other than that, sorry I don't know.

  5. #5
    SitePoint Wizard wonshikee's Avatar
    Join Date
    Jan 2007
    Posts
    1,223
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)
    Yes, I am looking for nicely indented XML file. It seems odd that every XML example has nicely formatted files and yet SimpleXML does nothing to replicate that.

  6. #6
    SitePoint Wizard silver trophybronze trophy Cups's Avatar
    Join Date
    Oct 2006
    Location
    France, deep rural.
    Posts
    6,869
    Mentioned
    17 Post(s)
    Tagged
    1 Thread(s)
    How are you viewing that xml output?

    $xml->asXML();

    Or saving it as a file and then viewing it in your browser? If the latter then make sure you have this line at the top:
    PHP Code:
    <?xml  version"1.0">
    My xml file looks fine in a browser.

  7. #7
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    Don't worry about it you will just cause more overhead trying to get a fancy output.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.



Bookmarks

Posting Permissions

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