473,698 Members | 2,295 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

XML elements to JavaScript Array elements Conversion

P
Hi,

I am finding it little harder to get this done, kindly help me.
I need to convert an XML file to a JavaScript file (Array) using XSLT,
1. Can I use <xsl:output method="text">?
2. I am suppose to convert the following pattern of XML to JavaScript
file like the one given below.
Input XML format:
<links>
<section1>
<name>SearchEng ines</name>
<url>www.search engines.com</url>
<section2>
<name>Google</name>
<url>www.google .com</url>
<section3>
<name>Groups</name>
<url>www.groups .google.com</url>
</section3>
<section3>
<name>Mail</name>
<url>www.gmail. com</url>
</section3>
</section2>
<section2>
<name>Yahoo</name>
<url>www.yahoo. com</url>
<section3>
<name>Photos</name>
<url>www.photos .yahoo.com</url>
</section3>
</section2>
</section1<!-- End of Section1 - I -->
<section1>
<name>Sample</name>
<url>www.sample .com</url>
<description> No section2 links are present for
this.</description>
</section1<!-- End of Section1 - II -->
<section1>
<name>Tutorials </name>
<url>www.tutori als.com</url>
<section2>
<name>XML</name>
<url>www.tutori als.com/xml</url>
<section3>
<name>XSLT</name>
<url>www.tutori als.com/xml/xslt</url>
</section3>
</section2>

</section1<!-- End of Section1 - III -->
</links>

Output JavaScript File: ( we need to make the values of the elements as
arrays, naming for Each section's array has to be like it is given
here.)

//Section1 Entries
Array1 = [
[170, 120 // Few Hardcoded values
],
["SearchEngines" ,"www.searcheng ines.com",1,0,1], // few values are
hardcoded here 1,0,1
["Sample","www.s ample.com",1,0, 1],
["Tutorials","ww w.tutorials.com ",1,0,1],
]

//Section2 entries of Section1 I
Array1_1 = [
[],
["Google","www.g oogle.com",1,0, 0], // few values are hardcoded here
1,0,0
["Yahoo","www.ya hoo.com",1,0,0],
]

//Section2 entries of Section1 II - when description is present for
Section 1, it should be given as section 2 link as well
Array1_2 = [
[],
["No section2 links are present for this.","www.sam ple.com",1,0,0],
]

//Section2 entries of Section1 III
Array1_3 = [
[],
["XML","www.tuto rials.com/xml",1,0,0],
]

// Section 3 entries

Array1_1_1 = [
[],
["Groups","www.g roups.google.co m",1,0,0], // few values are hardcoded
here 1,0,0
["Mail","www.gma il.com",1,0,0],
]

Kindly let me know, how to do this kind of conversion from XML to
JavaScript using XSLT

Thank you,

Regards,
Annbu P

Jul 7 '06 #1
1 3820
P wrote:
1. Can I use <xsl:output method="text">?
Yes.
Kindly let me know, how to do this kind of conversion from XML to
JavaScript using XSLT
There's a lot of good XSLT instructional information on the web; my
standard recommendations are the tutorials and articles on IBM's
DeveloperWorks website (http://www.ibm.com/xml) and, for the stuff that
isn't immediately obvious after reading those articles, the XSLT FAQ at
http://www.dpawson.co.uk/xsl/index.html

(Folks here, and on most mailing lists, will be much more willing to
answer specific questions than general requests that we do your homework
for you...)
Jul 7 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
7999
by: lawrence | last post by:
If I'm pretty sure there is just one form on the page, can i do this? var myForm = document.forms; If I'm not sure about the form, is it safer to do this? if (document.forms) { var myForm = document.forms; // more code here........ }
5
6521
by: Denis Perelyubskiy | last post by:
Hello, I need to make an array of elements accross forms. My javascript skills, as evident from this question, are rather rudimentary. I tried to make an associative array and index it with the object references. However, I just realized that indices may only be referenced by strings.
8
1977
by: JS | last post by:
I am trying to add an element to an array like this: var ty = ; zz = "ty"; var ab = null; zz+=""; ab = eval(zz); document.write(ab.length);
11
2253
by: Jon Hoowes | last post by:
Hi, I have inherited some code that has some form elements (radio buttons) that are called "1", "2" etc. for example: <input name="2" type="radio" value="45"> <input name="2" type="radio" value="46">
3
6923
by: Newcomsas | last post by:
Hello, I'm trying to solve a problem with JS textbox array without success. I have two buttons in my page: PLUS and MINUS; at every click on PLUS a new textbox named 'dear' is generated. So, if one clicks, say, 3 times the output is something like: dear dear dear
24
4381
by: RyanTaylor | last post by:
I have a final coming up later this week in my beginning Java class and my prof has decided to give us possible Javascript code we may have to write. Problem is, we didn't really cover JS and what we covered was within the last week of the class and all self taught. Our prof gave us an example of a Java method used to remove elements from an array: public void searchProcess() { int outIt=0;
11
2236
by: shankwheat | last post by:
I have a function which passes text from txtdebt to debtsbox which works fine. However, I want to add code which examines the value of debtsbox and if any of the values the user entered contain the string "d" then I want to emable rblDebts which is disabled when the page loads. This part is not working (no errors) and I'm not sure why. Thanks. <script type="text/javascript" language="JavaScript"> <!-- Begin oldvalue = "";
9
5346
by: Tuxedo | last post by:
I'd like to reorganize the third, fourth, fifth and sixth, as well as any elements thereafter in an array in random order: var a = new Array('first','second','third','fourth','fifth','sixth','etc') In other words, the first, second and third element should remain in position 0, 1 and 2, while the fourth, fifth and sixth, etc. should appear in random order. Can anyone recommend a method to do this?
4
2639
by: Norman | last post by:
I am trying to find a way to implement something like: <FORM name='form1'><TABLE> server scripting loop (php), generates X (a variable number) lines with the 3 fields { <TR><TD><input type='text' name='kminicial'></TD> <TD><input type='text' name='kmfinal' onBlur='document.form1.kmrodados.value=document.form1.kmfinal.value- document.form1.kminicial.value'></TD> <TD><input type='text' name='kmrodados'></TD></TR>
0
8604
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9028
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8895
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8861
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
7728
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6518
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4369
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2330
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2001
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.