Professional Web Applications Themes

XML, carriage returns and special characters. - Macromedia Flash

Hi, I'm trying to add dinamic content to my site using Flash and XML. Here is an example: <?xml version="1.0" encoding="utf-8"?> <PHOTOS> <photo image = "AlmanaqueFuerteventura" title = "Fuerteventura, Spirit of the Sea" text = "Image belonging to the Spirits from the Canary Islands series. Photography: Óscar Rivilla, Stylist: Carlos Nieves."/> <photo image = "DarkWarrior" title = "Carlos Diez Dark Warrior" text = "blah blah blah blah blah blah"/> </PHOTOS> "image" is the name of a jpeg file (without the extension), "title" is a title to be inserted in a text box and "text" is a text for another text ...

  1. #1

    Default XML, carriage returns and special characters.

    Hi,

    I'm trying to add dinamic content to my site using Flash and XML. Here
    is an example:

    <?xml version="1.0" encoding="utf-8"?>
    <PHOTOS>
    <photo
    image = "AlmanaqueFuerteventura"
    title = "Fuerteventura, Spirit of the Sea"
    text = "Image belonging to the Spirits from the Canary Islands series.
    Photography: Óscar Rivilla, Stylist: Carlos Nieves."/>
    <photo
    image = "DarkWarrior"
    title = "Carlos Diez Dark Warrior"
    text = "blah blah blah blah blah blah"/>
    </PHOTOS>

    "image" is the name of a jpeg file (without the extension), "title" is a
    title to be inserted in a text box and "text" is a text for another text
    box explaining the image.

    I've had success in using special characters (like in "Óscar") by adding
    the encoding "utf-8", but I still can't find any information on how can
    i begin in a new line before the words "Photography" and "Stylist" in
    that text so the text appears this neat way:

    Image belonging to the Spirits from the
    Canary Islands series.
    Photography: Óscar Rivilla,
    Stylist: Carlos Nieves.

    instead of this awful way:

    Image belonging to the Spirits from the
    Canary Islands series. Photography: Óscar
    Rivilla, Stylist: Carlos Nieves.

    NOTE: width of the text box is:
    [---------------------------------------]
    So the line feeds added automatically by Flash to the unformated text.

    Any solution or a different approach to the problem?

    Thanks in Advance,
    Johnny Walker
    Johnny Walker Guest

  2. #2

    Default Re: XML, carriage returns and special characters.


    "Johnny Walker" <johnnywalkerfake.address.com> wrote in message
    news:cqt5t6$ec4$1nsnmrro2-gest.nuria.telefonica-data.net...
    > Hi,
    >
    > I'm trying to add dinamic content to my site using Flash and XML. Here is
    > an example:
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <PHOTOS>
    > <photo
    > image = "AlmanaqueFuerteventura"
    > title = "Fuerteventura, Spirit of the Sea"
    > text = "Image belonging to the Spirits from the Canary Islands series.
    > Photography: Óscar Rivilla, Stylist: Carlos Nieves."/>
    > <photo
    > image = "DarkWarrior"
    > title = "Carlos Diez Dark Warrior"
    > text = "blah blah blah blah blah blah"/>
    > </PHOTOS>
    >
    > "image" is the name of a jpeg file (without the extension), "title" is a
    > title to be inserted in a text box and "text" is a text for another text
    > box explaining the image.
    >
    > I've had success in using special characters (like in "Óscar") by adding
    > the encoding "utf-8", but I still can't find any information on how can i
    > begin in a new line before the words "Photography" and "Stylist" in that
    > text so the text appears this neat way:
    >
    > Image belonging to the Spirits from the
    > Canary Islands series.
    > Photography: Óscar Rivilla,
    > Stylist: Carlos Nieves.
    >
    > instead of this awful way:
    >
    > Image belonging to the Spirits from the
    > Canary Islands series. Photography: Óscar
    > Rivilla, Stylist: Carlos Nieves.
    >
    > NOTE: width of the text box is:
    > [---------------------------------------]
    > So the line feeds added automatically by Flash to the unformated text.
    >
    > Any solution or a different approach to the problem?
    >
    > Thanks in Advance,
    > Johnny Walker
    Try "\n"


    Unabogie Guest

  3. #3

    Default Re: XML, carriage returns and special characters.

    Y dijo Unabogie, el 29/12/2004 5:52:<br>
    > Try "\n"
    It doesn't work. It just shows the \n on the screen but doesn't insert a
    line feed.

    Johnny Walker
    Johnny Walker Guest

  4. #4

    Default Re: XML, carriage returns and special characters.


    "Johnny Walker" <johnnywalkerfake.address.com> wrote in message
    news:cr0lg9$kt5$1nsnmrro2-gest.nuria.telefonica-data.net...
    >Y dijo Unabogie, el 29/12/2004 5:52:<br>
    >> Try "\n"
    >
    > It doesn't work. It just shows the \n on the screen but doesn't insert a
    > line feed.
    >
    > Johnny Walker
    Can you paste the XML and the actionscript code again?


    Unabogie Guest

  5. #5

    Default Re: XML, carriage returns and special characters.

    Y dijo Unabogie, el 30/12/2004 18:12:<br>
    > Can you paste the XML and the actionscript code again?
    Sure! XML is:
    <?xml version="1.0" encoding="utf-8"?>
    <PHOTOS>
    <photo
    text = "Image belonging to the Spirits from the Canary Islands
    series. Photography: Óscar Rivilla, Stylist: Carlos Nieves."/>
    <photo
    text = "blah blah blah blah blah blah"/>
    </PHOTOS>

    (I simplified it a bit to concentrate just on the problem)

    Another approach I'm using is placing the text in the node instead of
    the attributes:

    <?xml version="1.0" encoding="utf-8"?>
    <PHOTOS>
    <photo>
    Image belonging to the Spirits from the Canary Islands series.
    Photography: Óscar Rivilla
    Stylist: Carlos Nieves.
    </photo>
    <photo>
    blah blah blah blah blah blah
    </photo>
    </PHOTOS>

    The action script changes a little and the text appears with linefeeds
    in the correct place, but with 2 linefeeds instead of one and also adds
    linefeeds at the beginig and end of text.

    The action scipt for the first XML is:

    System.useCodepage = true;
    XML.prototype.ignoreWhite = true;
    photo= new Array();
    datos = new XML();
    datos.load("photos.xml");
    datos.onLoad = function(){
    for(i=0; i<this.firstChild.childNodes.length;i++) {
    photo[i] = this.firstChild.childNodes[i].attributes.text;
    }
    nextFrame();
    }
    stop();

    The result is one line of text broken just at the end of the text box:
    |-----------------------------------------|
    |Image belonging to the Spirits from the |
    |Canary Islands series. Photography: Óscar|
    |Rivilla, Stylist: Carlos Nieves. |
    |-----------------------------------------|

    For the second XML, the only change is the line inside the "for" loop,
    refering to the node value instead of the attribute:
    photo[i] = this.firstChild.childNodes[i].firstChild.nodeValue;

    The result in this case is:
    |---------------------------------------|
    | |
    | |
    |Image belonging to the Spirits from the|
    |Canary Islands series. |
    | |
    | |
    |Photography: Óscar Rivilla |
    | |
    | |
    |Stylist: Carlos Nieves. |
    | |
    | |
    |---------------------------------------|

    But all I want is this:
    |---------------------------------------|
    |Image belonging to the Spirits from the|
    |Canary Islands series. |
    |Photography: Óscar Rivilla |
    |Stylist: Carlos Nieves. |
    |---------------------------------------|

    Johnny Walker
    Johnny Walker Guest

  6. #6

    Default Re: XML, carriage returns and special characters.


    "Johnny Walker" <johnnywalkerfake.address.com> wrote in message
    news:cr7lc9$4m6$1nsnmrro2-gest.nuria.telefonica-data.net...
    >Y dijo Unabogie, el 30/12/2004 18:12:<br>
    >
    >> Can you paste the XML and the actionscript code again?
    >
    > Sure! XML is:
    > <?xml version="1.0" encoding="utf-8"?>
    > <PHOTOS>
    > <photo
    > text = "Image belonging to the Spirits from the Canary Islands series.
    > Photography: Óscar Rivilla, Stylist: Carlos Nieves."/>
    > <photo
    > text = "blah blah blah blah blah blah"/>
    > </PHOTOS>
    >
    > (I simplified it a bit to concentrate just on the problem)
    >
    > Another approach I'm using is placing the text in the node instead of the
    > attributes:
    >
    > <?xml version="1.0" encoding="utf-8"?>
    > <PHOTOS>
    > <photo>
    > Image belonging to the Spirits from the Canary Islands series.
    > Photography: Óscar Rivilla
    > Stylist: Carlos Nieves.
    > </photo>
    > <photo>
    > blah blah blah blah blah blah
    > </photo>
    > </PHOTOS>
    >
    > The action script changes a little and the text appears with linefeeds in
    > the correct place, but with 2 linefeeds instead of one and also adds
    > linefeeds at the beginig and end of text.
    >
    > The action scipt for the first XML is:
    >
    > System.useCodepage = true;
    > XML.prototype.ignoreWhite = true;
    > photo= new Array();
    > datos = new XML();
    > datos.load("photos.xml");
    > datos.onLoad = function(){
    > for(i=0; i<this.firstChild.childNodes.length;i++) {
    > photo[i] = this.firstChild.childNodes[i].attributes.text;
    > }
    > nextFrame();
    > }
    > stop();
    >
    > The result is one line of text broken just at the end of the text box:
    > |-----------------------------------------|
    > |Image belonging to the Spirits from the |
    > |Canary Islands series. Photography: Óscar|
    > |Rivilla, Stylist: Carlos Nieves. |
    > |-----------------------------------------|
    >
    > For the second XML, the only change is the line inside the "for" loop,
    > refering to the node value instead of the attribute:
    > photo[i] = this.firstChild.childNodes[i].firstChild.nodeValue;
    >
    > The result in this case is:
    > |---------------------------------------|
    > | |
    > | |
    > |Image belonging to the Spirits from the|
    > |Canary Islands series. |
    > | |
    > | |
    > |Photography: Óscar Rivilla |
    > | |
    > | |
    > |Stylist: Carlos Nieves. |
    > | |
    > | |
    > |---------------------------------------|
    >
    > But all I want is this:
    > |---------------------------------------|
    > |Image belonging to the Spirits from the|
    > |Canary Islands series. |
    > |Photography: Óscar Rivilla |
    > |Stylist: Carlos Nieves. |
    > |---------------------------------------|
    >
    > Johnny Walker
    Well, this is a hack, but:

    Put a delimiter in your xml:

    XML:

    <xml>
    <PHOTOS>
    <photo text = "Image belonging to the Spirits from the Canary Islands
    series. Photography: Óscar Rivilla, Stylist: Carlos Nieves."/>
    </PHOTOS>
    </xml>

    FLASH:

    System.useCodepage = true;
    XML.prototype.ignoreWhite = true;
    photo = new Array();
    datos = new XML();
    datos.load("photos.xml");
    datos.onLoad = function() {
    for (i=0; i<this.firstChild.childNodes.length; i++) {
    var myText = "";
    myVar = new Array();
    myVar =
    this.firstChild.childNodes[i].firstChild.attributes.text.split("");
    for (var j = 0; j<myVar.length; j++) {
    myText += myVar[j]+" \n";
    }
    photo[i] = myText;
    trace(photo[i]);
    }
    };
    stop();


    Unabogie Guest

  7. #7

    Default Re: XML, carriage returns and special characters.

    Thanks for the solution. As you said, it is a hack, but I'm using it
    until I find a more formal solution (if it exists).

    Thanks again and Happy new Year!

    Johnny Walker

    Y dijo Unabogie, el 02/01/2005 20:20:<br>
    > "Johnny Walker" <johnnywalkerfake.address.com> wrote in message
    > news:cr7lc9$4m6$1nsnmrro2-gest.nuria.telefonica-data.net...
    >
    >>Y dijo Unabogie, el 30/12/2004 18:12:<br>
    >>
    >>>Can you paste the XML and the actionscript code again?
    >>
    >>Sure! XML is:
    >><?xml version="1.0" encoding="utf-8"?>
    >><PHOTOS>
    >> <photo
    >> text = "Image belonging to the Spirits from the Canary Islands series.
    >>Photography: Óscar Rivilla, Stylist: Carlos Nieves."/>
    >> <photo
    >> text = "blah blah blah blah blah blah"/>
    >></PHOTOS>
    >>
    >>(I simplified it a bit to concentrate just on the problem)
    >>
    >>Another approach I'm using is placing the text in the node instead of the
    >>attributes:
    >>
    >><?xml version="1.0" encoding="utf-8"?>
    >><PHOTOS>
    >> <photo>
    >>Image belonging to the Spirits from the Canary Islands series.
    >>Photography: Óscar Rivilla
    >>Stylist: Carlos Nieves.
    >> </photo>
    >> <photo>
    >>blah blah blah blah blah blah
    >> </photo>
    >></PHOTOS>
    >>
    >>The action script changes a little and the text appears with linefeeds in
    >>the correct place, but with 2 linefeeds instead of one and also adds
    >>linefeeds at the beginig and end of text.
    >>
    >>The action scipt for the first XML is:
    >>
    >>System.useCodepage = true;
    >>XML.prototype.ignoreWhite = true;
    >>photo= new Array();
    >>datos = new XML();
    >>datos.load("photos.xml");
    >>datos.onLoad = function(){
    >> for(i=0; i<this.firstChild.childNodes.length;i++) {
    >> photo[i] = this.firstChild.childNodes[i].attributes.text;
    >> }
    >> nextFrame();
    >>}
    >>stop();
    >>
    >>The result is one line of text broken just at the end of the text box:
    >>|-----------------------------------------|
    >>|Image belonging to the Spirits from the |
    >>|Canary Islands series. Photography: Óscar|
    >>|Rivilla, Stylist: Carlos Nieves. |
    >>|-----------------------------------------|
    >>
    >> For the second XML, the only change is the line inside the "for" loop,
    >>refering to the node value instead of the attribute:
    >>photo[i] = this.firstChild.childNodes[i].firstChild.nodeValue;
    >>
    >>The result in this case is:
    >>|---------------------------------------|
    >>| |
    >>| |
    >>|Image belonging to the Spirits from the|
    >>|Canary Islands series. |
    >>| |
    >>| |
    >>|Photography: Óscar Rivilla |
    >>| |
    >>| |
    >>|Stylist: Carlos Nieves. |
    >>| |
    >>| |
    >>|---------------------------------------|
    >>
    >>But all I want is this:
    >>|---------------------------------------|
    >>|Image belonging to the Spirits from the|
    >>|Canary Islands series. |
    >>|Photography: Óscar Rivilla |
    >>|Stylist: Carlos Nieves. |
    >>|---------------------------------------|
    >>
    >>Johnny Walker
    >
    >
    > Well, this is a hack, but:
    >
    > Put a delimiter in your xml:
    >
    > XML:
    >
    > <xml>
    > <PHOTOS>
    > <photo text = "Image belonging to the Spirits from the Canary Islands
    > series. Photography: Óscar Rivilla, Stylist: Carlos Nieves."/>
    > </PHOTOS>
    > </xml>
    >
    > FLASH:
    >
    > System.useCodepage = true;
    > XML.prototype.ignoreWhite = true;
    > photo = new Array();
    > datos = new XML();
    > datos.load("photos.xml");
    > datos.onLoad = function() {
    > for (i=0; i<this.firstChild.childNodes.length; i++) {
    > var myText = "";
    > myVar = new Array();
    > myVar =
    > this.firstChild.childNodes[i].firstChild.attributes.text.split("");
    > for (var j = 0; j<myVar.length; j++) {
    > myText += myVar[j]+" \n";
    > }
    > photo[i] = myText;
    > trace(photo[i]);
    > }
    > };
    > stop();
    >
    >
    Johnny Walker Guest

Similar Threads

  1. Removing carriage returns...
    By JakeFlynn in forum Macromedia ColdFusion
    Replies: 3
    Last Post: April 5th, 08:54 PM
  2. replacing carriage returns in file
    By the real rob rone in forum Macromedia ColdFusion
    Replies: 1
    Last Post: March 17th, 05:35 PM
  3. replacing carriage returns?
    By yawnmoth in forum PHP Development
    Replies: 1
    Last Post: November 1st, 11:57 AM
  4. Carriage returns/formatting not displayed in output.asp
    By Doc Wally in forum ASP Database
    Replies: 9
    Last Post: October 11th, 11:48 PM
  5. Extra carriage returns - why?
    By Bob Walton in forum PERL Miscellaneous
    Replies: 3
    Last Post: September 10th, 11:35 AM

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
  •  

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