Content is not allowed in prolog

Ask a Question related to Macromedia Flex General Discussion, Design and Development.

  1. #1

    Default Content is not allowed in prolog

    I try php code attached (tree_source.php), but, in Flex Builder 3 application,
    line 43:

    <mx:XML id="dp" source="data/tree_source.php" />

    Flex show the error:

    "Problem parsing external XML: C:\xampp\htdocs\Tree
    Gallery\src\data\tree_source.php - (line 43) Content is not allowed in prolog."

    ??? Any help me, please.

    Thnak in advance

    tree_source.php
    --------------------------------------------------
    <?php
    $path = "images";

    echo '<?xml version="1.0" encoding="UTF-8"?>' . "\n";
    echo "<root>"."\n";

    structure($path,$path);

    echo "</root>";


    // Function
    function structure($rootdirpath,$dir)
    {
    unset($root);
    if($dp = @opendir($rootdirpath))
    {
    for($i=0;($file=readdir($dp))!==false;$i++)
    {
    if (is_dir($rootdirpath."/".$file) && $file != "." && $file != "..")
    {
    echo "<node label=\"".$file."\">"."\n";
    structure($rootdirpath."/".$file,$dir);
    echo "</node>\n\r";
    }
    }
    }
    closedir($dp);
    }

    ?>
    ------------------------------------------------

    Flex Builder 3 code:
    ------------------------------------------------------
    <?xml version="1.0" encoding="utf-8"?>
    <mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
    layout="absolute"
    width="100%" height="100%">

    <mx:Script>
    <![CDATA[
    import mx.events.ListEvent;
    import mx.collections.ICollectionView;
    import mx.events.ListEvent;

    private function tree_itemClick(evt:ListEvent):void {
    var t:Tree = evt.currentTarget as Tree;
    var dataObj:Object = evt.itemRenderer.data;

    var item:Object = Tree(evt.currentTarget).selectedItem;
    if (tree.dataDescriptor.isBranch(item)) {
    tree.expandItem(item, !tree.isItemOpen(item), true);
    }

    if (dataObj.hasOwnProperty("@src")) {
    swfLoader.source = dataObj.@src;
    } else if (t.dataDescriptor.isBranch(t.selectedItem)) {
    swfLoader.source = null;
    panel.status = "";
    }
    }

    private function tree_labelFunc(item:Object):String {
    var suffix:String = "";
    if (tree.dataDescriptor.isBranch(item)) {
    suffix = " (" + item.children().length() + ")";
    }
    return item.@label + suffix;
    }

    private function swfLoader_complete(evt:Event):void {
    panel.status = (swfLoader.bytesTotal/1024).toFixed(2) + 'KB';
    }
    ]]>
    </mx:Script>

    <mx:XML id="dp" source="data/tree_source.php"></mx:XML>

    <mx:HDividedBox width="100%" height="100%" horizontalCenter="12"
    verticalCenter="12">
    <mx:Panel width="200" height="100%">
    <mx:Tree id="tree"
    dataProvider="{dp}"
    labelFunction="tree_labelFunc"
    showRoot="false"
    width="100%"
    height="100%"
    itemClick="tree_itemClick(event);" />
    </mx:Panel>
    <mx:Panel id="panel"
    width="100%"
    height="100%"
    backgroundColor="white">
    <mx:SWFLoader id="swfLoader"
    scaleContent="true"
    width="100%"
    height="100%"
    complete="swfLoader_complete(event);" horizontalAlign="center"
    verticalAlign="middle"/>
    <mx:ControlBar>
    <mx:LinkButton label="{swfLoader.source.toString()}" />
    </mx:ControlBar>
    </mx:Panel>
    </mx:HDividedBox>

    </mx:Application>
    -----------------------------------------------------

    fisad Guest

  2. Similar Questions and Discussions

    1. Literal content is not allowed within a CustomControl?
      Is there a way to put content between tags of a custom control so that it will populate the defaultproperty such as my TabLabel property? When I...
    2. Need help with Content-Disposition Content-Type
      I am trying to use the following script to allow users to download files with some of the file name stripped off. This script is for use on my...
    3. PDF security - printing allowed but changes not allowed?
      Adobe Acrobat 6 Professional - on a PC. how can i restrict changes to a pdf while allowing printing? i don't want to have to give passwords or...
    4. Prolog like facilities.
      Somebody asked me to do something that was partially solved by tsort, but the next step exceeds the limitations of tsort. After a bit of thought...
  3. #2

    Default Re: Content is not allowed in prolog

    execute this : C:\xampp\htdocs\Tree Gallery\src\data\tree_source.php
    in your browser and make sure xml has no spaces or some other chars on top, or somewhere else, it must be well formed xml.
    levancho Guest

  4. #3

    Default Re: Content is not allowed in prolog

    I execute code in browser and don't show has no spaces or some other chars
    somewhere, I saved with notepad in correct format but nothing.

    I have following code for create xml file with php, this xml file read correct
    in Flex:

    -------------------------------------
    <?php
    $path = "images";

    $fp=fopen("data/tree_source.xml","w");
    fwrite($fp,'<?xml version="1.0" encoding="UTF-8"?>' . "\n");
    fwrite($fp,"<root>"."\n");

    structure($path,$fp,$path);

    fwrite($fp,"</root>");
    fclose($fp);


    // Function
    function structure($rootdirpath,$fp,$dir)
    {
    unset($root);
    if($dp = @opendir($rootdirpath))
    {
    for($i=0;($file=readdir($dp))!==false;$i++)
    {
    if (is_dir($rootdirpath."/".$file) && $file != "." && $file != "..")
    {
    fwrite($fp,"<node label=\"".$file."\">"."\n");
    structure($rootdirpath."/".$file,$fp,$dir);
    fwrite($fp,"</node>\n\r");
    }

    }
    }
    closedir($dp);

    }


    ?>
    ------------------------------

    I need know how execute this code from Flex at any time for refresh contens of
    tree, one at start application, other when de directory structure has changed.

    Any example code for help me, please.

    Thank in advance-


    fisad Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139