help newbie with reading XML problem

Ask a Question related to Macromedia Flash, Design and Development.

  1. #1

    Default help newbie with reading XML problem

    I try to read the value from XML file,
    it read, but come out all wrong, I don't understand why, here is the code,
    can someone help me out?
    thanks ahead!
    Willy

    AS code
    ===========================
    my_XML = new XML();
    my_XML.onLoad = convertXML;
    my_display = "Loading data ... ";
    my_XML.load("data.xml");
    var fileList = new Array();
    var thumList = new Array();
    var nViewList = new Array();
    var cViewList = new Array();
    var titleList = new Array();
    var detailList = new Array();
    var editionList = new Array();
    var madeList = new Array();
    var dateList = new Array();
    function convertXML() {
    if (this.loaded) {
    my_display = "Data loaded.";
    }
    var mainTag = new XML();
    var imageTag = new XML();
    var no_i = 0;
    var mainTag = this.firstChild.nextSibling;
    if (mainTag.nodeName.toLowerCase() == "files") {
    fileList = mainTag.childNodes;
    my_display = "";
    for (i=0; i<=mainTag.childNodes.length; i++) {
    my_display = "---"+mainTag.childNodes.length;
    if (fileList[i].nodeName.toLowerCase() == "image") {
    //we get the child node array beneath the articles, aka the meat and
    potatoes we are after
    imageList = fileList[i].childNodes;
    //and loop through that looking for the data we need
    for (j=1; j<=imageList.length; j++) {
    imageTag = imageList[j];
    myTitle="<br>"+imageList.length;
    imageType = imageTag.nodeName.toLowerCase();
    if (imageType == "filename") {
    fileList[no_i] = imageTag.firstChild.nodeValue;
    no_i++;
    }
    if (imageType == "thumbnail") {
    thumList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    if (imageType == "normalview") {
    nViewList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    if (imageType == "closeview") {
    cViewList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    if (imageType == "detail") {
    detailList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    if (imageType == "title") {
    titleList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    if (imageType == "edition") {
    editionList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    if (imageType == "made") {
    madeList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    if (imageType == "date") {
    dateList[no_i-1] = imageTag.firstChild.nodeValue;
    }
    }
    // end for j
    }
    // end if image
    }
    // end for i
    }
    // end if files
    for (i=0; i<=fileList.length; i++) {
    //i_list += "<br>i="+i+" "+"<br>i="+fileList[i]+"<br>i="+i+"
    "+thumList[i]+"<br>i="+i+" "+nViewList[i]+"<br>i="+i+"
    "+cViewList[i]+"<br>i="+i+" "+detailList[i]+"<br>i="+i+"
    "+titleList[i]+"<br>i="+i+" "+madeList[i]+"<br>i="+i+"
    "+dateList[i]+"<br><br>==============<br><br>";
    i_list +=
    "i="+i+"<br>"+"fileList="+fileList[i]+"<br>"+"thumList="+thumList[i]+"<br>"+
    "nViewList="+nViewList[i]+"<br>"+"cViewList="+cViewList[i]+"<br>"+"detailLis
    t="+detailList[i]+"<br>"+"titleList="+titleList[i]+"<br>"+"madeList="+madeLi
    st[i]+"<br>"+"dateList="+dateList[i]+"<br>"+"<br><br>==============<br><br>"
    ;
    }
    }
    ===========================

    XML file
    ============================
    <?xml version="1.0" encoding="utf-8"?>
    <files>
    <image id="1">
    <filename>01</filename>
    <thumbnail>images/1_0.jpg</thumbnail>
    <normalview>images/1_1.jpg</normalview>
    <closeview>images/1_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail xml:space="preserve">The marbles remind me of my playful
    youth,
    but they also are symbolic of my maturation; most scattered marbles
    contain
    a Chinese brush painted lotus or venerable-Buddhist symbols that
    represent my goal of gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="2">
    <filename>02</filename>
    <thumbnail>images/2_0.jpg</thumbnail>
    <normalview>images/2_1.jpg</normalview>
    <closeview>images/2_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="3">
    <filename>03</filename>
    <thumbnail>images/3_0.jpg</thumbnail>
    <normalview>images/3_1.jpg</normalview>
    <closeview>images/3_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="4">
    <filename>04</filename>
    <thumbnail>images/4_0.jpg</thumbnail>
    <normalview>images/4_1.jpg</normalview>
    <closeview>images/4_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="5">
    <filename>05</filename>
    <thumbnail>images/5_0.jpg</thumbnail>
    <normalview>images/5_1.jpg</normalview>
    <closeview>images/5_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="6">
    <filename>06</filename>
    <thumbnail>images/6_0.jpg</thumbnail>
    <normalview>images/6_1.jpg</normalview>
    <closeview>images/6_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="7">
    <filename>07</filename>
    <thumbnail>images/7_0.jpg</thumbnail>
    <normalview>images/7_1.jpg</normalview>
    <closeview>images/7_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="8">
    <filename>08</filename>
    <thumbnail>images/8_0.jpg</thumbnail>
    <normalview>images/8_1.jpg</normalview>
    <closeview>images/8_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="9">
    <filename>09</filename>
    <thumbnail>images/9_0.jpg</thumbnail>
    <normalview>images/9_1.jpg</normalview>
    <closeview>images/9_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="10">
    <filename>10</filename>
    <thumbnail>images/10_0.jpg</thumbnail>
    <normalview>images/10_1.jpg</normalview>
    <closeview>images/10_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    <image id="11">
    <filename>11</filename>
    <thumbnail>images/11_0.jpg</thumbnail>
    <normalview>images/11_1.jpg</normalview>
    <closeview>images/11_2.jpg</closeview>
    <title>Marble Series, No. three</title>
    <detail>The marbles remind me of my playful youth, but they also are
    symbolic of my maturation; most scattered marbles contain a Chinese brush
    painted lotus or venerable-Buddhist symbols that represent my goal of
    gradual enlightenment.</detail>
    <edition>40" * 59", 8 editions</edition>
    <made>ink jet print on acetate or mount on plexi glass</made>
    <date>2003/2004</date>
    </image>
    </files>

    ==============================


    hsin Guest

  2. Similar Questions and Discussions

    1. Newbie asking for help - Reading a text file of qurantined emails and parsing contents.
      Greetings. Please excuse this post if it is about something that is very simple or have been discussed before, as I am newbie in PHP, and failed...
    2. [newbie]saving and reading array of associative array
      i'm looking for examples of saving to file and reading back an array of associative array, in a ruby like way. saying i have something like : ...
    3. newbie question: reading from mysql
      Hi, I am trying to read some info from my mysql tables and display it. This is what I have now which works: $select = "SELECT `name` FROM...
    4. Newbie - Reading File Contents
      Hi All - Can I get some help here. I am parsing a file delimited by |. For some reason the content is displayed to the browser properly - but the...
    5. newbie cocoa file reading/writing files
      I am working on an application that presents only one window. This window contains a number of controls, and an NSTextView. I would like to...
  3. #2

    Default Re: help newbie with reading XML problem

    On Fri, 28 Jan 2005 11:45:04 -0500, "hsin" <hsinhsin@comcast.net>
    wrote:

    The easy way to do it is use a textarea and then use

    content.multiline= true;
    content.wordWrap = true;
    content.html = true;

    story = new XML();
    story.ignoreWhite = true;
    story.html = true;
    story.wordWrap = true;
    story.load("help.xml");
    story.onLoad = function () {
    content.htmlText = story;
    }

    you can see it working @
    [url]http://www.janwright.co.uk/war[/url]

    The secret is to use a stye sheet to do the formating ie
    BODY {SCROLLBAR-FACE-COLOR: #8080FF; SCROLLBAR-HIGHLIGHT-COLOR:
    #89A3B4; SCROLLBAR-SHADOW-COLOR: #000000; SCROLLBAR-3DLIGHT-COLOR:
    #000000; SCROLLBAR-ARROW-COLOR: #FFFF80; SCROLLBAR-TRACK-COLOR:
    #004080; SCROLLBAR-DARKSHADOW-COLOR: #000000; border: medium groove
    #C0C0C0; cursor: default; outline: #f9bd64 ridge; accelerator: true;
    border-style: groove groove ridge ridge; text-align: justify;
    border-color: transparent; border-bottom-color: silver;
    border-left-color: silver; border-right-color: gray; border-top-color:
    gray; border-bottom-style: groove; border-left-style: groove;
    border-right-style: ridge; border-top-style: ridge; border-top:
    groove; border-right: ridge; border-bottom: ridge; border-left: ridge}
    body, td, left, p, div {
    font-family: verdana;
    font-size: 9pt;
    }
    headline {font-family: Arial,Helvetica,sans-serif; font-size: 16px;
    font-weight: bold; display: list-item; color: #0000CC}
    subheadline {font-family: Arial,Helvetica,sans-serif; font-size: 12px;
    font-weight: bold; display: list-item}
    mainBody {font-family: Arial,Helvetica,sans-serif; font-size: 10px;
    display: Block}
    biline {
    font-family: Arial,Helvetica,sans-serif; font-size: 8px; font-style:
    italic; display:inline; }
    A {
    font-family: Arial,Helvetica,sans-serif; color: cccccc; font-size:
    12px; display: table; text-decoration: underline}

    >I try to read the value from XML file,
    >it read, but come out all wrong, I don't understand why, here is the code,
    >can someone help me out?
    >thanks ahead!
    >Willy
    >
    >AS code
    >===========================
    >my_XML = new XML();
    >my_XML.onLoad = convertXML;
    >my_display = "Loading data ... ";
    >my_XML.load("data.xml");
    >var fileList = new Array();
    >var thumList = new Array();
    >var nViewList = new Array();
    >var cViewList = new Array();
    >var titleList = new Array();
    >var detailList = new Array();
    >var editionList = new Array();
    >var madeList = new Array();
    >var dateList = new Array();
    >function convertXML() {
    > if (this.loaded) {
    > my_display = "Data loaded.";
    > }
    > var mainTag = new XML();
    > var imageTag = new XML();
    > var no_i = 0;
    > var mainTag = this.firstChild.nextSibling;
    > if (mainTag.nodeName.toLowerCase() == "files") {
    > fileList = mainTag.childNodes;
    > my_display = "";
    > for (i=0; i<=mainTag.childNodes.length; i++) {
    > my_display = "---"+mainTag.childNodes.length;
    > if (fileList[i].nodeName.toLowerCase() == "image") {
    > //we get the child node array beneath the articles, aka the meat and
    >potatoes we are after
    > imageList = fileList[i].childNodes;
    > //and loop through that looking for the data we need
    > for (j=1; j<=imageList.length; j++) {
    > imageTag = imageList[j];
    > myTitle="<br>"+imageList.length;
    > imageType = imageTag.nodeName.toLowerCase();
    > if (imageType == "filename") {
    > fileList[no_i] = imageTag.firstChild.nodeValue;
    > no_i++;
    > }
    > if (imageType == "thumbnail") {
    > thumList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > if (imageType == "normalview") {
    > nViewList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > if (imageType == "closeview") {
    > cViewList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > if (imageType == "detail") {
    > detailList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > if (imageType == "title") {
    > titleList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > if (imageType == "edition") {
    > editionList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > if (imageType == "made") {
    > madeList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > if (imageType == "date") {
    > dateList[no_i-1] = imageTag.firstChild.nodeValue;
    > }
    > }
    > // end for j
    > }
    > // end if image
    > }
    > // end for i
    > }
    > // end if files
    > for (i=0; i<=fileList.length; i++) {
    > //i_list += "<br>i="+i+" "+"<br>i="+fileList[i]+"<br>i="+i+"
    >"+thumList[i]+"<br>i="+i+" "+nViewList[i]+"<br>i="+i+"
    >"+cViewList[i]+"<br>i="+i+" "+detailList[i]+"<br>i="+i+"
    >"+titleList[i]+"<br>i="+i+" "+madeList[i]+"<br>i="+i+"
    >"+dateList[i]+"<br><br>==============<br><br>";
    > i_list +=
    >"i="+i+"<br>"+"fileList="+fileList[i]+"<br>"+"thumList="+thumList[i]+"<br>"+
    >"nViewList="+nViewList[i]+"<br>"+"cViewList="+cViewList[i]+"<br>"+"detailLis
    >t="+detailList[i]+"<br>"+"titleList="+titleList[i]+"<br>"+"madeList="+madeLi
    >st[i]+"<br>"+"dateList="+dateList[i]+"<br>"+"<br><br>==============<br><br>"
    >;
    > }
    >}
    >===========================
    >
    >XML file
    >============================
    ><?xml version="1.0" encoding="utf-8"?>
    ><files>
    > <image id="1">
    > <filename>01</filename>
    > <thumbnail>images/1_0.jpg</thumbnail>
    > <normalview>images/1_1.jpg</normalview>
    > <closeview>images/1_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail xml:space="preserve">The marbles remind me of my playful
    >youth,
    > but they also are symbolic of my maturation; most scattered marbles
    >contain
    > a Chinese brush painted lotus or venerable-Buddhist symbols that
    > represent my goal of gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="2">
    > <filename>02</filename>
    > <thumbnail>images/2_0.jpg</thumbnail>
    > <normalview>images/2_1.jpg</normalview>
    > <closeview>images/2_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="3">
    > <filename>03</filename>
    > <thumbnail>images/3_0.jpg</thumbnail>
    > <normalview>images/3_1.jpg</normalview>
    > <closeview>images/3_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="4">
    > <filename>04</filename>
    > <thumbnail>images/4_0.jpg</thumbnail>
    > <normalview>images/4_1.jpg</normalview>
    > <closeview>images/4_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="5">
    > <filename>05</filename>
    > <thumbnail>images/5_0.jpg</thumbnail>
    > <normalview>images/5_1.jpg</normalview>
    > <closeview>images/5_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="6">
    > <filename>06</filename>
    > <thumbnail>images/6_0.jpg</thumbnail>
    > <normalview>images/6_1.jpg</normalview>
    > <closeview>images/6_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="7">
    > <filename>07</filename>
    > <thumbnail>images/7_0.jpg</thumbnail>
    > <normalview>images/7_1.jpg</normalview>
    > <closeview>images/7_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="8">
    > <filename>08</filename>
    > <thumbnail>images/8_0.jpg</thumbnail>
    > <normalview>images/8_1.jpg</normalview>
    > <closeview>images/8_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="9">
    > <filename>09</filename>
    > <thumbnail>images/9_0.jpg</thumbnail>
    > <normalview>images/9_1.jpg</normalview>
    > <closeview>images/9_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="10">
    > <filename>10</filename>
    > <thumbnail>images/10_0.jpg</thumbnail>
    > <normalview>images/10_1.jpg</normalview>
    > <closeview>images/10_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    > <image id="11">
    > <filename>11</filename>
    > <thumbnail>images/11_0.jpg</thumbnail>
    > <normalview>images/11_1.jpg</normalview>
    > <closeview>images/11_2.jpg</closeview>
    > <title>Marble Series, No. three</title>
    > <detail>The marbles remind me of my playful youth, but they also are
    >symbolic of my maturation; most scattered marbles contain a Chinese brush
    >painted lotus or venerable-Buddhist symbols that represent my goal of
    >gradual enlightenment.</detail>
    > <edition>40" * 59", 8 editions</edition>
    > <made>ink jet print on acetate or mount on plexi glass</made>
    > <date>2003/2004</date>
    > </image>
    ></files>
    >
    >==============================
    >
    Samuria Guest

  4. #3

    Default Re: help newbie with reading XML problem

    thanks for the help, I think i didn't make it clear what is wrong with my
    code,
    i mean after my code read the XML file, all the elements are mess up.



    "Samuria" <samuria@rock.com> wrote in message
    news:mcflv0tca0gdb2er2s2h7ri6f8bqdmbsbf@4ax.com...
    > On Fri, 28 Jan 2005 11:45:04 -0500, "hsin" <hsinhsin@comcast.net>
    > wrote:
    >
    > The easy way to do it is use a textarea and then use
    >
    > content.multiline= true;
    > content.wordWrap = true;
    > content.html = true;
    >
    > story = new XML();
    > story.ignoreWhite = true;
    > story.html = true;
    > story.wordWrap = true;
    > story.load("help.xml");
    > story.onLoad = function () {
    > content.htmlText = story;
    > }
    >
    > you can see it working @
    > [url]http://www.janwright.co.uk/war[/url]
    >
    > The secret is to use a stye sheet to do the formating ie
    > BODY {SCROLLBAR-FACE-COLOR: #8080FF; SCROLLBAR-HIGHLIGHT-COLOR:
    > #89A3B4; SCROLLBAR-SHADOW-COLOR: #000000; SCROLLBAR-3DLIGHT-COLOR:
    > #000000; SCROLLBAR-ARROW-COLOR: #FFFF80; SCROLLBAR-TRACK-COLOR:
    > #004080; SCROLLBAR-DARKSHADOW-COLOR: #000000; border: medium groove
    > #C0C0C0; cursor: default; outline: #f9bd64 ridge; accelerator: true;
    > border-style: groove groove ridge ridge; text-align: justify;
    > border-color: transparent; border-bottom-color: silver;
    > border-left-color: silver; border-right-color: gray; border-top-color:
    > gray; border-bottom-style: groove; border-left-style: groove;
    > border-right-style: ridge; border-top-style: ridge; border-top:
    > groove; border-right: ridge; border-bottom: ridge; border-left: ridge}
    > body, td, left, p, div {
    > font-family: verdana;
    > font-size: 9pt;
    > }
    > headline {font-family: Arial,Helvetica,sans-serif; font-size: 16px;
    > font-weight: bold; display: list-item; color: #0000CC}
    > subheadline {font-family: Arial,Helvetica,sans-serif; font-size: 12px;
    > font-weight: bold; display: list-item}
    > mainBody {font-family: Arial,Helvetica,sans-serif; font-size: 10px;
    > display: Block}
    > biline {
    > font-family: Arial,Helvetica,sans-serif; font-size: 8px; font-style:
    > italic; display:inline; }
    > A {
    > font-family: Arial,Helvetica,sans-serif; color: cccccc; font-size:
    > 12px; display: table; text-decoration: underline}
    >
    >
    > >I try to read the value from XML file,
    > >it read, but come out all wrong, I don't understand why, here is the
    code,
    > >can someone help me out?
    > >thanks ahead!
    > >Willy
    > >
    > >AS code
    > >===========================
    > >my_XML = new XML();
    > >my_XML.onLoad = convertXML;
    > >my_display = "Loading data ... ";
    > >my_XML.load("data.xml");
    > >var fileList = new Array();
    > >var thumList = new Array();
    > >var nViewList = new Array();
    > >var cViewList = new Array();
    > >var titleList = new Array();
    > >var detailList = new Array();
    > >var editionList = new Array();
    > >var madeList = new Array();
    > >var dateList = new Array();
    > >function convertXML() {
    > > if (this.loaded) {
    > > my_display = "Data loaded.";
    > > }
    > > var mainTag = new XML();
    > > var imageTag = new XML();
    > > var no_i = 0;
    > > var mainTag = this.firstChild.nextSibling;
    > > if (mainTag.nodeName.toLowerCase() == "files") {
    > > fileList = mainTag.childNodes;
    > > my_display = "";
    > > for (i=0; i<=mainTag.childNodes.length; i++) {
    > > my_display = "---"+mainTag.childNodes.length;
    > > if (fileList[i].nodeName.toLowerCase() == "image") {
    > > //we get the child node array beneath the articles, aka the meat and
    > >potatoes we are after
    > > imageList = fileList[i].childNodes;
    > > //and loop through that looking for the data we need
    > > for (j=1; j<=imageList.length; j++) {
    > > imageTag = imageList[j];
    > > myTitle="<br>"+imageList.length;
    > > imageType = imageTag.nodeName.toLowerCase();
    > > if (imageType == "filename") {
    > > fileList[no_i] = imageTag.firstChild.nodeValue;
    > > no_i++;
    > > }
    > > if (imageType == "thumbnail") {
    > > thumList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > if (imageType == "normalview") {
    > > nViewList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > if (imageType == "closeview") {
    > > cViewList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > if (imageType == "detail") {
    > > detailList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > if (imageType == "title") {
    > > titleList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > if (imageType == "edition") {
    > > editionList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > if (imageType == "made") {
    > > madeList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > if (imageType == "date") {
    > > dateList[no_i-1] = imageTag.firstChild.nodeValue;
    > > }
    > > }
    > > // end for j
    > > }
    > > // end if image
    > > }
    > > // end for i
    > > }
    > > // end if files
    > > for (i=0; i<=fileList.length; i++) {
    > > //i_list += "<br>i="+i+" "+"<br>i="+fileList[i]+"<br>i="+i+"
    > >"+thumList[i]+"<br>i="+i+" "+nViewList[i]+"<br>i="+i+"
    > >"+cViewList[i]+"<br>i="+i+" "+detailList[i]+"<br>i="+i+"
    > >"+titleList[i]+"<br>i="+i+" "+madeList[i]+"<br>i="+i+"
    > >"+dateList[i]+"<br><br>==============<br><br>";
    > > i_list +=
    >
    >"i="+i+"<br>"+"fileList="+fileList[i]+"<br>"+"thumList="+thumList[i]+"<br>"
    +
    >
    >"nViewList="+nViewList[i]+"<br>"+"cViewList="+cViewList[i]+"<br>"+"detailLi
    s
    >
    >t="+detailList[i]+"<br>"+"titleList="+titleList[i]+"<br>"+"madeList="+madeL
    i
    >
    >st[i]+"<br>"+"dateList="+dateList[i]+"<br>"+"<br><br>==============<br><br>
    "
    > >;
    > > }
    > >}
    > >===========================
    > >
    > >XML file
    > >============================
    > ><?xml version="1.0" encoding="utf-8"?>
    > ><files>
    > > <image id="1">
    > > <filename>01</filename>
    > > <thumbnail>images/1_0.jpg</thumbnail>
    > > <normalview>images/1_1.jpg</normalview>
    > > <closeview>images/1_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail xml:space="preserve">The marbles remind me of my playful
    > >youth,
    > > but they also are symbolic of my maturation; most scattered marbles
    > >contain
    > > a Chinese brush painted lotus or venerable-Buddhist symbols that
    > > represent my goal of gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="2">
    > > <filename>02</filename>
    > > <thumbnail>images/2_0.jpg</thumbnail>
    > > <normalview>images/2_1.jpg</normalview>
    > > <closeview>images/2_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="3">
    > > <filename>03</filename>
    > > <thumbnail>images/3_0.jpg</thumbnail>
    > > <normalview>images/3_1.jpg</normalview>
    > > <closeview>images/3_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="4">
    > > <filename>04</filename>
    > > <thumbnail>images/4_0.jpg</thumbnail>
    > > <normalview>images/4_1.jpg</normalview>
    > > <closeview>images/4_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="5">
    > > <filename>05</filename>
    > > <thumbnail>images/5_0.jpg</thumbnail>
    > > <normalview>images/5_1.jpg</normalview>
    > > <closeview>images/5_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="6">
    > > <filename>06</filename>
    > > <thumbnail>images/6_0.jpg</thumbnail>
    > > <normalview>images/6_1.jpg</normalview>
    > > <closeview>images/6_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="7">
    > > <filename>07</filename>
    > > <thumbnail>images/7_0.jpg</thumbnail>
    > > <normalview>images/7_1.jpg</normalview>
    > > <closeview>images/7_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="8">
    > > <filename>08</filename>
    > > <thumbnail>images/8_0.jpg</thumbnail>
    > > <normalview>images/8_1.jpg</normalview>
    > > <closeview>images/8_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="9">
    > > <filename>09</filename>
    > > <thumbnail>images/9_0.jpg</thumbnail>
    > > <normalview>images/9_1.jpg</normalview>
    > > <closeview>images/9_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="10">
    > > <filename>10</filename>
    > > <thumbnail>images/10_0.jpg</thumbnail>
    > > <normalview>images/10_1.jpg</normalview>
    > > <closeview>images/10_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > > <image id="11">
    > > <filename>11</filename>
    > > <thumbnail>images/11_0.jpg</thumbnail>
    > > <normalview>images/11_1.jpg</normalview>
    > > <closeview>images/11_2.jpg</closeview>
    > > <title>Marble Series, No. three</title>
    > > <detail>The marbles remind me of my playful youth, but they also
    are
    > >symbolic of my maturation; most scattered marbles contain a Chinese brush
    > >painted lotus or venerable-Buddhist symbols that represent my goal of
    > >gradual enlightenment.</detail>
    > > <edition>40" * 59", 8 editions</edition>
    > > <made>ink jet print on acetate or mount on plexi glass</made>
    > > <date>2003/2004</date>
    > > </image>
    > ></files>
    > >
    > >==============================
    > >
    >

    hsin 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