Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > XML > Problem accessing an element

Reply
Thread Tools

Problem accessing an element

 
 
rosemm
Guest
Posts: n/a
 
      01-21-2005
I am having a problem accessing an element in an XML document (one that
I receive from someone else). The xml looks like this

<FAMILY>
<DAD>
<ADDRESS>
<ADDRESS_LINE VALUE="SOMETHING"/>
<ADDRESS_LINE VALUE="SOMETHING ELSE"/>
...................
</ADDRESS>
<MOM>
</MOM>
</FAMILY>
<FAMILY>
<DAD>
<ADDRESS>
<ADDRESS_LINE VALUE="SOMETHING"/>
..............
</ADDRESS>
<MOM>
</MOM>
</FAMILY>

I am creating a CSV. I need to have an , , if there is no second
ADDRESS_LINE. However, I can't even seem to access the second address
line in my code. Here is what I have so far.


<xsl:value-of select="normalize-space(ADDRESS_LINE/@VALUE)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="ADDRESS/CITY/@VALUE"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="ADDRESS/STATE/@VALUE"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="ADDRESS/ZIP/@VALUE"/>
<xsl:text>,</xsl:text>

Help!!!

 
Reply With Quote
 
 
 
 
Joris Gillis
Guest
Posts: n/a
 
      01-21-2005
Tempore 19:57:17, die Friday 21 January 2005 AD, hinc in foro {comp.text.xml} scripsit rosemm <(E-Mail Removed)>:

> I am creating a CSV. I need to have an , , if there is no second
> ADDRESS_LINE. However, I can't even seem to access the second address
> line in my code. Here is what I have so far.

Hi,

Try this:

<xsl:value-of select="normalize-space(ADDRESS_LINE[1]/@VALUE)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="normalize-space(ADDRESS_LINE[2]/@VALUE)"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="ADDRESS/CITY/@VALUE"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="ADDRESS/STATE/@VALUE"/>
<xsl:text>,</xsl:text>
<xsl:value-of select="ADDRESS/ZIP/@VALUE"/>
<xsl:text>,</xsl:text>


regards,
--
Joris Gillis (http://www.ticalc.org/cgi-bin/acct-v...i?userid=38041)
Fiat W3C !
 
Reply With Quote
 
 
 
 
rosemm
Guest
Posts: n/a
 
      01-21-2005
That doesn't work. I get the following error

ERROR: Description: Expression must evaluate to a node-set.
-->normalize-space(ADDRESS/ADDRESS_LINE[1]/@VALUE)<--

 
Reply With Quote
 
rosemm
Guest
Posts: n/a
 
      01-21-2005
Thanks. I typed something else wrong. That soultion works perfect!!!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to Update/insert an xml element's text----> (<element>text</element>) HANM XML 2 01-29-2008 03:31 PM
problem: create element in create element Iulian Ilea Javascript 4 12-17-2006 12:00 PM
Element in a td accessing parent <tr> element Christopher Benson-Manica Javascript 3 03-30-2005 04:03 PM
moving from form element to form element Rod Snyder ASP .Net 1 05-29-2004 01:55 PM
per the active schema, the element <BR> must be included within a parent element MSNews ASP .Net 1 04-22-2004 04:45 PM



Advertisments