473,804 Members | 2,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

problem with commas when parsing xml file

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:

<DestinationAdd ress>
<City>Leawood </City>
<StateOrProvinc eCode>KS</StateOrProvince Code>
<PostalCode>662 09</PostalCode>
<CountryCode>US </CountryCode>
</DestinationAddr ess>
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:

, LeawoodKS662009 US

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

....
var objXMLDOM = Server.CreateOb ject("MSXML2.DO MDocument");
objXMLDOM.loadX ML(objXMLHttp.r esponseText);
objXMLDOM.async = false;

var Address = objXMLDOM.getEl ementsByTagName ("DestinationAd dress");

var AddressText = "";

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

Response.Write( AddressText);
Jul 19 '05 #1
1 1348
Allan wrote:
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:

<DestinationAdd ress>
<City>Leawood </City>
<StateOrProvinc eCode>KS</StateOrProvince Code>
<PostalCode>662 09</PostalCode>
<CountryCode>US </CountryCode>
</DestinationAddr ess>
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:

, LeawoodKS662009 US

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

...
var objXMLDOM = Server.CreateOb ject("MSXML2.DO MDocument");
objXMLDOM.loadX ML(objXMLHttp.r esponseText);
I prefer
objXMLDOM.load( objXMLHttp.resp onseXML);
objXMLDOM.async = false;

var Address = objXMLDOM.getEl ementsByTagName ("DestinationAd dress");
No:

var Address = objXMLDOM.selec tSingleNode("//DestinationAddr ess");

var AddressText = "";

for (var i = 0; i < Address.length; i++)
for (var=0;var<Addr ess.childNodes. length; i++)
{
AddressText = AddressText + ", " + Address.item(i) .text }
AddressText += (AddressText.le ngth==0)?Addres s.childNodes(i) .text : ", " +
Address.childNo des(i).text;

Response.Write( AddressText);


--
Microsoft MVP - ASP/ASP.NET
Please reply to the newsgroup. This email account is my spam trap so I
don't check it very often. If you must reply off-line, then remove the
"NO SPAM"
Jul 19 '05 #2

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

Similar topics

2
1445
by: Allan | last post by:
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>
6
1796
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 but not for "AAA","BBB","CCC","DDD". Here is an extract from the code which needs to be modified for the """: Sub LoadTextFile(ByVal strFilePath As String) Dim oDS As New DataSet() Dim strFields As String Dim oTable As New DataTable()
1
9757
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 control. It outputs all text fields surrounded by quotes, and all numeric fields w/o quotes. All fields are separated with commas. This has been working for 2 years, until today, when one of the data fields
4
2490
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, three,four,,,,,,,,,,eighteen, and so on. There is one time when multiple commas are allowed. Just prior to the letters ADMNSRC there should be one instance of 4 commas. ( ,eight,,,,ADMNSRC,thirteen, ). The text ADMNSRC is NOT in the same
27
5157
by: comp.lang.tcl | last post by:
My TCL proc, XML_GET_ALL_ELEMENT_ATTRS, is supposed to convert an XML file into a TCL list as follows: attr1 {val1} attr2 {val2} ... attrN {valN} This is the TCL code that does this: set contents ]; close $fileID
12
3410
by: Julian | last post by:
Hi, I am having problems with a function that I have been using in my program to read sentences from a 'command file' and parse them into commands. the surprising thing is that the program works fine on some computers and not so fine on others. I tried debugging and cannot make any sense of it. I narrowed it down to the seekg function and made this simple program which (from what I understand) does not seem to be working as expected in all...
7
2857
by: souravmallik | last post by:
Hello, I'm facing a big logical problem while writing a parser in VC++ using C. I have to parse a file in a chunk of bytes in a round robin fashion. Means, when I select a file, the parser will read first 512kb(IBUFFSIZE) of data, then move to next file and parse the same way. This way I can parse a number of file spreaded over different directory uniformly. I'm keeping a meta data in a file where I'm keeping the track of file parse...
2
2059
gregerly
by: gregerly | last post by:
I'm having an issue parsing a CSV file in which some fields contain commas. My CSV looks something like this: 123,asdflkj23klj,"Sept. 22, 2008",some field,one more field,"Aug 1,1983" To parse my csv files I was reading it into an array with file(), and then looping the lines, exploding by comma, IE explode(',',$line), however this doesn't work as it will explode the commas in the date fields. I guess my main question is how do I...
4
4805
by: E11esar | last post by:
Hi there. This could be a curious one. Has anybody come across a solution to remove stray commas that appear within strings in a CSV file please? In effect I have many address fields that are punctuated with commas and I am looking for a way to remove these while parsing the csv file. Any ideas will be most appreciated please. Thank you.
0
10569
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10315
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
10075
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
9140
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
7615
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
6847
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5519
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...
1
4295
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3815
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.