473,402 Members | 2,050 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

How to split one XML into smaller XML; received via a XMLHttpRequest?

Hi!

After sending a request to a server via XMLHttpRequest and receiving a
response, I assign an incoming XML from a server via
[...]
var root = request.responseXML.documentElement;
[...]
to the variable root which I process further with root.nodeType,
root.nodeValue, etc...

In my example I have the following XML File:
<activities>
<day date="20061001">
<activity>I did this</activity>
<activity>I did that</activity)
</day>
<day date="20061002">
<activity>I was doing this</activity>
<activity>And this</activity>
<activity>And that</activity>
</day>
<day date="20061003">
<activity>and so on</activity>
</day>
</activities>

Now here is my question: How can I assign the big XML (root:
activities) into e.g. three smaller XML's (with the new root: day) to
an array?

Thanks,

Norbert

Jan 3 '07 #1
1 1780
On Jan 3, 3:16 pm, "NorbertH" <norbert.kell...@myegrannie.comwrote:
<activities>
<day date="20061001">
<activity>I did this</activity>
<activity>I did that</activity)
</day>
<day date="20061002">
<activity>I was doing this</activity>
<activity>And this</activity>
<activity>And that</activity>
</day>
<day date="20061003">
<activity>and so on</activity>
</day>
</activities>

Now here is my question: How can I assign the big XML (root:
activities) into e.g. three smaller XML's (with the new root: day) to
an array?
var days = root.getElementsByTagName("day");

days will now be an array of "day" nodes. You could also use XPath, but
of course IE doesn't support the DOM Level 3 XPath standard, so you'll
have to do some feature detection. In this simple case
getElementsByTagName would suffice.

Cheers
Chad

Jan 4 '07 #2

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

Similar topics

2
by: brad | last post by:
I have an XMLDocument that my web page downloads and manipulates as a response to user input. I have lots of JavaScript that acts as a controller between my view (html) and my model (xml). That...
5
by: mikeyjudkins | last post by:
Ive been banging my head on the wall for hours with this one, hopefully someone will know what Im doing wrong here :\ The Goal: I have an xml file that is generated on the fly via JSP which I...
2
by: horndude77 | last post by:
Ok, I've been reading around a lot and haven't found an answer for this. I'm using XMLHttpRequest to get an XML document from a java servlet. When the response is processed I can view the text of...
76
by: kwilder | last post by:
This works, but it doesn't load the latest version of the xml if it was just modified without closing and reopening the browser. Here's the scenario: I have an xml doc called results.xml. It...
2
by: dondraper | last post by:
I have an application that uses a popular but simple set of JavaScript routines that implement an AJAX call used to populate a drop-down. It works for thousands of user but I have one customer...
3
by: SM | last post by:
Hello, Im trying to access elements in my XML file using the JavaScript DOM but i'm not sure how. I use AJAX to access the XML and then use the responseXML property to access the XML file data. I...
1
by: Tarik Monem | last post by:
OK, I'm pretty sure this cannot work because I'm trying to use JavaScript (client-side) to write to an xml file (which is server-side) using XMLHttpRequest. Can I use PHP do what I'm trying to do?...
5
by: Benoit | last post by:
I've been instructing myself in XML DOM parsing using the w3schools tutorial and decided to try an example of my own. I'd written a short XML file that looked like this: <?xml version="1.0"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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...
0
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...
0
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...
0
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,...
0
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...

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.