15 Replies Latest reply: May 27, 2009 7:42 AM by redbarron50 RSS

    Line Break in XML?

      When I use "<br>" within my XML database, I get this error:
      "Expected end of tag 'br'(9,43)"

      I have tried <br>, </br>, <br></br> and searched... but haven't yet found a solution.

      Should I be using some kind of hex code?

      Thanks in advance for the assistance!

      Dan
        • 1. Re: Line Break in XML?
          kinblas Community Member
          I'm not exactly sure what you are trying to do, but in XML, if you have a tag that does *not* have a close tag, then you must use a slash at the end of the tag:

          <br/>

          --== Kin ==--
          • 2. Re: Line Break in XML?
            Community Member
            Sorry, all that did was invalidate the code, causing that string to just not appear.

            I have a long line of script that I'm trying to break into more than one line.

            <Series>text text text <br> text text text</Series>

            Sometimes this invalidates the code and displays nothing. Sometimes this invalidates the XML itself, causing the error mentioned before.

            Thanks for your assistance.

            Dan
            • 3. Re: Line Break in XML?
              Donald Booth Community Member
              If you are going to use complex data like that, with open/close brackets and markup, you should use a CDATA block.
              http://www.w3schools.com/xml/xml_cdata.asp
              Let us know if that helps.
              Don
              • 4. Re: Line Break in XML?
                Community Member
                I think that's the answer. I haven't tested it, but with the link you supplied, I think I can manage.

                Thanks for the help!

                Dan
                • 5. Re: Line Break in XML?
                  Community Member
                  Yes, using the CDATA block fixed the problem. Thank you for your help!

                  • 6. Re: Line Break in XML?
                    Type-Style Community Member
                    Hey this is exactly the problem i am fighting with.
                    I don´t know anything about CDATA so what do I need to get a <br /> in my XML?
                    What did you do?
                    • 7. Re: Line Break in XML?
                      Community Member
                      Just use the code "<![CDATA[" at the beginning of the tag and "]]>" at the end (without quotes).

                      <tag><![CDATA[
                      ]]></tag>

                      See the following page for more:
                      http://www.w3schools.com/xml/xml_cdata.asp

                      quote:

                      CDATA - (Unparsed) Character Data The term CDATA is used about text data that should not be parsed by the XML parser. Characters like "<" and "&" are illegal in XML elements. "<" will generate an error because the parser interprets it as the start of a new element. "&" will generate an error because the parser interprets it as the start of an character entity. Some text, like JavaScript code, contains a lot of "<" or "&" characters. To avoid errors script code can be defined as CDATA. Everything inside a CDATA section is ignored by the parser. A CDATA section starts with "<![CDATA[" and ends with "]]>":
                      • 8. Line Break in XML?
                        Type-Style Community Member
                        Ok thanks for this tip.

                        This is working, but not as i want it to.
                        My Code is like this:
                        <Info>This Picture was created by<![CDATA[ <br /> ]]>
                        Type-Style back in 2007. </Info>

                        And what this does is:
                        This Picture was created by <br /> Type-Style back in 2007.

                        It displays the <br> Tag but it doesn´t make a linebreak at that point.

                        How to make a real break at that point?



                        • 9. Re: Line Break in XML?
                          Community Member
                          You want the code instead like this:

                          <Info><![CDATA[This Picture was created by<br />
                          Type-Style back in 2007. ]]></Info>

                          Then you can insert any code between the CDATA tags and it should work.
                          • 10. Line Break in XML?
                            Type-Style Community Member
                            I am sorry but i have to tell, that it does not work.
                            There is still an <br /> displayed on that Page.

                            Maybe i should tell you what i want to do.
                            I just saw the "taming the web" episode "building a Database driven Page".
                            So i wanted to test that.

                            And here ist my XML document.
                            http://www.communicators.ag/003/Content.xml
                            There is a slidly diffrent content but it is still the same problem.
                            And if you are looking in the Code of this XML you will see that i did it just like you told me to do.

                            Whats wrong with that? Is this a server-problem? Or do i have to change my xml declaration?


                            • 11. Re: Line Break in XML?
                              Arnout Kazemier Community Member
                              U need to set a column type for your html so Spry knows its needs to be renderd as html..

                              datasetname.setColumnType('rowname','html');
                              • 12. Re: Line Break in XML?
                                Type-Style Community Member
                                Well i put it in my js file, but this doesn ´t change it.
                                Is it a Problem that i used a div for it?

                                And the XML itself does display the <br/> signs, even though the CDATA.
                                I think that is the Problem.
                                • 13. Re: Line Break in XML?
                                  Arnout Kazemier Community Member
                                  I checked your js files, and its not in there. add it under your dataset..
                                  • 14. Re: Line Break in XML?
                                    Type-Style Community Member
                                    I´ve got good news.
                                    It work´s.

                                    var ds1 = new Spry.Data.XMLDataSet("Content.xml", "Box/Content");
                                    ds1.setColumnType('Info','html');

                                    I didn´t checked that 'Info' has to be the name of the XML Tag. That was the key.

                                    So i thank you all!
                                    • 15. Re: Line Break in XML?
                                      redbarron50

                                      I spent a whole bloody day trying to solve this one!  Thanks for the advice here guys....

                                       

                                      Here's the "How to..." instructions I made for myself (I will need this later as a function of age)....

                                       

                                      Inserting <br /> line breaks in XML content:

                                       

                                      It's necessary to add a line of code directly after the dataset at the top of the (spry) htm page that sets the columnType:

                                       

                                      var dsRegInfoElem = new Spry.Data.XMLDataSet("regisinfo.xml", "sites/level1/site",{distinctOnLoad:true});
                                      dsRegInfoElem.setColumnType('datetime','html');<!--This line is necessary for the line breaks in the xml CDATA sections to work-->

                                       

                                      Make sure the xml tag that will contain the CDATA wrap is identified (here it's the <datetime> tag).

                                       

                                      Then, in the XML file, add the CDATA wrap just inside the tag like this:

                                       

                                      <datetime><![CDATA[texttexttexttext]]></datetime>

                                       

                                      Now just insert the <br /> where I need it!

                                       

                                      <datetime><![CDATA[texttext<br />texttext]]></datetime>