Wrox Programmer Forums

Need to download code?

View our list of code downloads.

| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Javascript How-To Ask your "How do I do this with Javascript?" questions here.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Javascript How-To section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old October 30th, 2003, 02:33 PM
Friend of Wrox
 
Join Date: Jun 2003
Location: High Wycombe, UK, United Kingdom.
Posts: 344
Thanks: 0
Thanked 1 Time in 1 Post
Default XML and NN

Dear All,
    I've got a small JS app that uses XML and I've got it working fine in IE, but not in NN, I've used plenty of the samples on the web with my Netscape Communicator and NN 6.1 but they just to seem to solve the problem. The relevant code is below :

Code:
var text = new Array();
var header = new Array();
var linka = new Array();
var targa = new Array();
var newsItems;

// create an XMLDoc
var xmldoc;

if (document.implementation && document.implementation.createDocument)
{
    xmldoc = document.implementation.createDocument("", "", null);
}
else if (window.ActiveXObject)
{
    // create a new XML object for IE
    xmldoc=new ActiveXObject("Microsoft.XMLDOM");
}
else
{
    alert('Your browser can\'t handle this script');
}

// define some attributes of the doc
xmldoc.async = false;

//load the XML file in
xmldoc.load('news.xml');

// load the moves
newsItems = xmldoc.getElementsByTagName("newselement");

// populate the Move Arrays from the XML file
for (var i=0;i<newsItems.length;i++)
{
    // add the move
    text[i]=newsItems[i].getElementsByTagName("headline")[0].firstChild.data;
    header[i]=newsItems[i].getElementsByTagName("newsitem")[0].firstChild.data;
    linka[i]=newsItems[i].getElementsByTagName("newslink")[0].firstChild.data;
    targa[i]=newsItems[i].getElementsByTagName("newstarget")[0].firstChild.data;
}
with the XML file being used as follows :

Code:
<newsticker>
    <newselement>
        <newsno>1</newsno>
        <headline>This is Headline 1</headline>
        <newsitem>This is NI 1</newsitem>
        <newslink>helloWorld.html</newslink>
        <newstarget>a</newstarget>
    </newselement>
    <newselement>
        <newsno>2</newsno>
        <headline>This is Headline 2</headline>
        <newsitem>This is NI 2</newsitem>
        <newslink>http://www.greggriffiths.org/</newslink>
        <newstarget>new</newstarget>
    </newselement>    
    <newselement>
        <newsno>3</newsno>
        <headline>This is Headline 3</headline>
        <newsitem>This is NI 3</newsitem>
        <newslink>http://www.greggriffiths.org/</newslink>
        <newstarget>blank</newstarget>
    </newselement>        
</newsticker>
Can anyone help me out with this as it is driving me nuts !!
__________________
All the best

Greg
------------------
Greg Griffiths
Web & Livelink Developer
http://www.greggriffiths.org
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL Server 2005 XML: FOR XML PATH -> cdata? stoves SQL Server 2005 1 July 8th, 2008 02:40 AM
xml invalid top level from ASP write XML(solution) g000we XML 0 August 9th, 2006 03:56 AM
DTS Package, XML task. Read XML file and store it Victoria SQL Server DTS 0 July 24th, 2006 02:43 PM
JavaScript & XML & NN lmod Javascript How-To 0 August 18th, 2005 03:16 PM
XML and NN Greg Griffiths Javascript 1 October 31st, 2003 06:50 AM



All times are GMT -4. The time now is 09:40 PM.


Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.