Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Read data from XML file
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Malintha  
View profile  
 More options Aug 29 2012, 8:47 am
From: Malintha <mailtoadik...@gmail.com>
Date: Wed, 29 Aug 2012 05:47:01 -0700 (PDT)
Local: Wed, Aug 29 2012 8:47 am
Subject: Read data from XML file

Hi,

I want to read a XML file which has data for my extension. I want to read
that file inside the extension and put data to an array. I tried to create
DOM object parser and read from that object in my extension .But is not
working properly, Here is  part of my code

var systemPrincipal = Components.classes["@mozilla.org/systemprincipal;1"]
                      .createInstance(Components.interfaces.nsIPrincipal);

var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
             .createInstance(Components.interfaces.nsIDOMParser);

var doc = parser.parseFromString("<?xml version=1.0
encoding=ISO-8859-1?><TestSuite
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instancexsi:noNamespaceSchemaLocatio...

><TestCase name=logintoChorus><LoadPage>LoginPage<LoadPage/>    

</TestCase></TestSuite>", "application/xml");

alert(doc); //*this gives me the xmldoc object*

alert(doc.getElementByTagName("LoadPage"));  //*this gives me nothing*

I am new to DOM object also ? Can you give me any advice

Thanks


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastian Zartner  
View profile  
 More options Aug 29 2012, 8:55 am
From: Sebastian Zartner <sebastianzart...@gmail.com>
Date: Wed, 29 Aug 2012 14:55:27 +0200
Local: Wed, Aug 29 2012 8:55 am
Subject: Re: [firebug] Read data from XML file

> alert(doc.getElementByTagName("LoadPage"));  //*this gives me nothing*

You should use alert(doc.getElementsByTagName("LoadPage").item(0)) instead.
getElementsByTagName()<https://developer.mozilla.org/en-US/docs/DOM/element.getElementsByTag...>returns
an array-like
NodeList <https://developer.mozilla.org/en-US/docs/DOM/NodeList>.

Sebastian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Malintha  
View profile  
 More options Aug 29 2012, 9:09 am
From: Malintha <mailtoadik...@gmail.com>
Date: Wed, 29 Aug 2012 06:09:10 -0700 (PDT)
Local: Wed, Aug 29 2012 9:09 am
Subject: Re: Read data from XML file

var parser = Components.classes["@mozilla.org/xmlextras/domparser;1"]
             .createInstance(Components.interfaces.nsIDOMParser);

var doc = parser.parseFromString("<test><TestSuite>swg</TestSuite></test>",
"application/xml");

alert(doc.getElementByTagName("TestSuite").item(0));

//I thing i should have the alert "swg"    :(   but get nothing

--------------------------------------------------------------------------- --------------------------------------------------------------------

now this is my code. But still I get nothing. Is there any problem in the
method when I m  creating a DOM parser. Shall have to initialize it after
creating.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastian Zartner  
View profile  
 More options Aug 29 2012, 9:34 am
From: Sebastian Zartner <sebastianzart...@gmail.com>
Date: Wed, 29 Aug 2012 06:34:55 -0700 (PDT)
Local: Wed, Aug 29 2012 9:34 am
Subject: Re: Read data from XML file

Could it be that you just forgot the "s" in getElementsByTagName()?

Sebastian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastian Zartner  
View profile  
 More options Aug 29 2012, 9:37 am
From: Sebastian Zartner <sebastianzart...@gmail.com>
Date: Wed, 29 Aug 2012 06:37:52 -0700 (PDT)
Local: Wed, Aug 29 2012 9:37 am
Subject: Re: Read data from XML file

Ah, and you need to add .textContent at the end to get the tag's content.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Malintha  
View profile  
 More options Aug 29 2012, 12:15 pm
From: Malintha <mailtoadik...@gmail.com>
Date: Wed, 29 Aug 2012 09:15:52 -0700 (PDT)
Local: Wed, Aug 29 2012 12:15 pm
Subject: Re: Read data from XML file

Thanks Sebastian, It is working now  


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Sebastian Zartner  
View profile  
 More options Aug 31 2012, 2:03 am
From: Sebastian Zartner <sebastianzart...@gmail.com>
Date: Thu, 30 Aug 2012 23:03:08 -0700 (PDT)
Local: Fri, Aug 31 2012 2:03 am
Subject: Re: Read data from XML file

> Thanks Sebastian, It is working now

Great. If you have other issues like this I suggest you put your XML into a
separate file, load it inside the browser and try out your DOM functions
using the Firebug Command Line<https://getfirebug.com/wiki/index.php/Command_Line>
.

Sebastian


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »