Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 7 of 7
  1. #1
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Error: empty-xml-tag-nodesValue

    Hi,

    I have an xml-file like:

    <index>

    <data>
    Hello
    </data>

    <data>
    World
    </data>

    <data>
    </data>

    </index>

    Thus the last data-tag without a value (empty), then I get an error message. When I make a file with a deeper structure and I leave the tag without value out of the file it's not working either, which in this case I can understand, but a Tag without value not working?

    Is it necessary to write a work-around, NAN? or how do I handle this?

    Thanks for Your effort,
    Jerome

  • #2
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,453
    Thanks
    1
    Thanked 21 Times in 19 Posts
    Um, what platform and script are you running that XML file through? The file is well-formed, so there's not much we can do to help you unless we know what you're trying to do, exactly.
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #3
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for replying, sorry for not being very clear, here are the details:

    1. HTML-file with JavaScript function
    2. External XML-file with data

    The JavaScript function:
    {
    nodelist=xmlDoc.getElementsByTagName("it");
    dataStr+='<TABLE>';
    for(i=0;i<=nodelist.length-1;i++)
    {
    a=nodelist[i].childNodes[0].childNodes[0].nodeValue;
    b=nodelist[i].childNodes[1].childNodes[0].nodeValue;
    c=nodelist[i].childNodes[2].childNodes[0].nodeValue;
    dataStr+='<TR><TD>'+a+'</TD><TD>'+b+'</TD><TD>'+c+'</TD></TR>';
    }
    dataStr+='</TABLE>';
    MyDIV.innerHTML=dataStr;
    }

    The XML-file:

    <?xml version="1.0"?>
    <kl2>
    <it>
    <tp>208</tp>
    <lt>1990 - 1992</lt>
    <lk>link1</lk>
    </it>
    <it>
    <tp>308</tp>
    <lt>1992 - 1994</lt>
    <lk>link2</lk>
    </it>
    <it>
    <tp>408</tp>
    <lt>1994 - 1996</lt>
    <lk>link3</lk>
    </it>
    <it>
    <tp>508</tp>
    <lt></lt>
    <lk>link4</lk>
    </it>
    </kl2>
    The question:

    I get an error when one of the childs has no value, in other words it's empty (see the last - lt - Tags).

    The XML-files I have are like this, sometimes no value available

    Is there a work-around to examen empty fields?

    Thanks for Your effort,
    Jerome
    Last edited by Jerome; 03-21-2003 at 10:25 AM.

  • #4
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,453
    Thanks
    1
    Thanked 21 Times in 19 Posts
    Hm. Well, NodeList interfaces have an item() method and a length property. childNodes properties are considered NodeList objects.

    Also, when you ask for a property from DOM which isn't there, you get a null value back.

    Here's what I'd do:

    Code:
     a=nodelist[i].childNodes[0].firstChild;
    b=nodelist[i].childNodes[1].firstChild;
    c=nodelist[i].childNodes[2].firstChild;
    if (a && b && c) {
    dataStr+='<TR><TD>'+a.nodeValue+'</TD><TD>'+b.nodeValue+'</TD><TD>'+c.nodeValue+'</TD></TR>';
    }
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog

  • #5
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hm., this means the complete -record - will not show up when one off 3 values not exist. However what I like is:

    a or b or c available.
    Show record (table.row) with filled or empty cells depending on the availabillity of a value, f.e.

    The table looks like:
    208 1990 - 1992 link1
    308 1992 - 1994 link2
    408 1994 - 1996 link3
    508 (empty cell) link4

    I think I have to examen a - null - or - NaN - value.

    Jerome

  • #6
    Regular Coder
    Join Date
    Oct 2002
    Posts
    299
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Alex,

    It has nothing to do with removing white-spaces, does it? Otherwise I am completely......I am using IE 5.0, where this should not happen.

    Your thread:

    Cleaning useless whitespace in Mozilla DOM

    I am running out of ideas to solve this!

    Jerome

  • #7
    Moderator
    Join Date
    May 2002
    Location
    Hayward, CA
    Posts
    1,453
    Thanks
    1
    Thanked 21 Times in 19 Posts
    No, I don't think it has anything to do with whitespace text nodes.

    I think you're very close; the key is how do you want to do the logic of the a, b, c flag variables?
    "The first step to confirming there is a bug in someone else's work is confirming there are no bugs in your own."
    June 30, 2001
    author, Verbosio prototype XML Editor
    author, JavaScript Developer's Dictionary
    https://alexvincent.us/blog


  •  

    Posting Permissions

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