473,396 Members | 1,770 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,396 software developers and data experts.

Problem with commas not showing up

Hi All,

I am having a problem parsing an xml file I am getting from another server.

This is the portion of the xml I am getting I am interested in:

<DestinationAddress>
<City>Leawood</City>
<StateOrProvinceCode>KS</StateOrProvinceCode>
<PostalCode>66209</PostalCode>
<CountryCode>US</CountryCode>
</DestinationAddress>
I am trying to write the above result in an html page as follow:

Leawood, KS, 662009, US

However my code keeps producing the following omitting the commas:

, LeawoodKS662009US

This is my code (I am using jscript!!)

....
var objXMLDOM = Server.CreateObject("MSXML2.DOMDocument");
objXMLDOM.loadXML(objXMLHttp.responseText);
objXMLDOM.async = false;

var Address = objXMLDOM.getElementsByTagName("DestinationAddress ");

var AddressText = "";

for (var i = 0; i < Address.length; i++)
{
AddressText = AddressText + ", " + Address.item(i).text }

Response.Write(AddressText);
Jul 20 '05 #1
2 1431
"Allan" <pr********@hotmail.com> wrote in message
news:7b**************************@posting.google.c om...
I am trying to write the above result in an html page as follow:

Leawood, KS, 662009, US

However my code keeps producing the following omitting the commas:

, LeawoodKS662009US
You want to process multiple text nodes, four of them in this example. But
your program is getting all the text at once.
var Address = objXMLDOM.getElementsByTagName("DestinationAddress ");
Now you have a handle on a sequence of elements, in this case a sequence of
length 1, containing the one DestinationAddress element.
for (var i = 0; i < Address.length; i++)
{
AddressText = AddressText + ", " + Address.item(i).text }


Indeed, your program is doing exactly what you told it to. :)

You need to get a node list containing the children nodes of the
DestinationAddress element and iterate over that list. Then for each
element, you need to get a node list containing the text node(s). (The DOM
API may break up a sequence of text into more than one text node.)

/kmc
Jul 20 '05 #2
"Keith M. Corbett" <km*@world.std.com> wrote in message
news:dJ********************@comcast.com...
for (var i = 0; i < Address.length; i++)
{
AddressText = AddressText + ", " + Address.item(i).text }


Also: this adds a comma every time through the loop. You only want to add a
comma after the first iteration.

/kmc
Jul 20 '05 #3

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

Similar topics

11
by: Fox | last post by:
Hi, Can anyone tell me how can I create a variable which will list numbers in a row and then use it in a CASE within a Select Case? I need it in a varaible because it has to be in an include...
22
by: ineedyourluvin1 | last post by:
Hello all! I've been looking for a way to strip characters from strings such as a comma. This would be great for using a comma as a delimiter. I show you what I have right now. ...
7
by: AES | last post by:
Encountered a URL containing a comma the other day -- the first time I've ever noticed that, so far as I can recall. It worked fine, however, and I gather commas are legal in URLs. Out of...
6
by: Skc | last post by:
I am trying to import a file using a custom VB.net procedure, but the problem is it works on a file with pure comma separation and not inverted commas and commas, i.e. it works for AAA,BBB,CCC,DDD...
1
by: DCM Fan | last post by:
Access 2K, SP3 on Windows 2K, SP4 All, I have an import spec set up with quoted Identifiers and comma-separated values. The text file is produced by a 3rd-party program of which I have no...
6
by: papa.coen | last post by:
Hi, I need to split/match the following type of (singleline) syntax on all commas (or text in between) that are not between qoutes: A,'B,B',C,,'E',F The text between quotes can be _any_ text...
3
by: Robert Scheer | last post by:
Hi. I have a regularexpression validator control on a page. This regular expression validates a textbox to accept only numbers and commas: validationexpression="*" I am trying to modify this...
4
by: striker | last post by:
I have a comma delimited text file that has multiple instances of multiple commas. Each file will contain approximatley 300 lines. For example: one, two, three,,,,four,five,,,,six one, two,...
8
by: dragoncoder | last post by:
Hi, I am just a newbie in STL and trying to learn istream_iterator. My problem is I want a program which will take a comma separated string from the command line, tokenize it and copies into a...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
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
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...
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
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,...

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.