7 Replies Latest reply on Dec 13, 2006 11:53 AM by ntsiii

    reading xml

    deFink
      I have difficulty understanding ex4.

      I have an xml file with chunks of text that contain various <name> elements:

      <items>
      <item>placeholder text <name>John</name> placeholder text <Mary> placeholder text ... etc...</item>
      <item>....................</item>
      etc.
      <items>

      How can I display the items as text with names and without the <name> tags?
      I tried and tried, but to no avail.
      I would be very grateful if you could help me out here.....!
        • 1. Re: reading xml
          ntsiii Level 3
          Try item.text().toString();

          Give me a real sample of the xml, maybe I will play with it.

          Tracy
          • 2. Re: reading xml
            deFink Level 1
            ok, Tracy, thanks. here is the xml:

            <?xml version='1.0' encoding='utf-8'?>
            <opus title='Aeneidos' author="Vergil'>
            <liber nr='1'>
            <excerpt>..........</excerpt>
            <text>
            <line nr="1">Arma virumque cano, <name>Troiae</name> qui primus ab oris</line>
            <line nr="2"><name>Italiam</name> fato profugus <name>Laviniaque</name> venit</line>
            <line nr="3">litora, multum ille et terris iactatus et alto</line>
            <line nr="4">vi superum, saevae memorem <name>Iunonis</name> ob iram,</line>
            ...........
            ..........
            </text>
            </liber>
            </opus>

            the xml comes in as text. of course it is easy to remove the tags from the xml string before i create the xml object, but then i would lose the information and i want to display the text with clickable names.
            i hope you can tell me how to achieve this!

            • 3. Re: reading xml
              ntsiii Level 3
              Are your dots literal characters in the xml, or are they indicating "more-of-the-same"? I need a REAL example of the xml, one I can work with.

              And how would you like to see this displayed?
              Tracy
              • 4. Re: reading xml
                deFink Level 1
                the dots are "more of the same" ( in total 756 lines).
                if possible, i would display the lines with linenumbers in a datagrid, but i don't know if the names can then be made clickable independent of the selectedItem... so, the display method is not of paramount importance. what matters is that the user can select both the entire line and singular names to get further info.
                thanks for trying to help!

                mac
                • 5. Re: reading xml
                  ntsiii Level 3
                  I have worked up one way to do this if you haven't figured it out yorself already.

                  It uses an item renderer to build html twxt, with the names as hyperlinks.

                  Let me know if you want to see it.

                  Tracy
                  • 6. Re: reading xml
                    deFink Level 1
                    I most definitely would like to see it!