BizTalk Utilities CV ,   Jobs ,   Code library
 
Home Page


Add/Edit your code items
Search the code library
Browse for the code library


Schemas, xsd, xdr
XML Code Generator: Generating Wrapper Classes from an XML Schema
What is WDDX?
XSLT Stylesheet for summarizing the structure of an XML document
Validating XML with Schemas
Punctuated Changes In XML Documents
XMLStarlet Command Line XML Toolkit
W2XML v2.0 SR1
Free DTD for Academic Publishers
Arquemie for XML Schemas
XMLStarlet Command Line XML/XSLT Toolkit
XSD Merger


 
 

<< reBloggerSEO >>


By Mark Wilson
I am the creator of TopXML. I am available for international and local (Australia) contracts. I am a Solution Architect/Business Analyst. I have worked in IT in several countries (NZ, Australia, South Africa, UK) building and training teams for government and very large non-governmental organizations. I am ex-Microsoft Consulting Services. I wrote the first book on Microsoft XML published in 2000 called XML Programming with VB and ASP. Most recently I have been building tools for the SEO industry. Ask me for a 37 point SEO health-checkup for your website.
First Posted 03/14/2002
Times viewed 189

Getting the value of an element with optional subelements


Summary Use XSLT to get the value of an element whether is has subselements or not.

Storing text in elements rather than attributes has an advantage because it is more easily extended.

Say you have the following XML snippet.

<name>Jim Smith</name>

The name can be extracted using the following XSLT:

<xsl:value-of select=name/>

This returns Jim Smith.

Now say you want to be able to distinguish the first name from the last name, so you add elements first and last as shown here.

<name>
<first>Jim</first>
<last>Smith</last>
</name>

You can still use the same XSLT as before to get the same result, Jim Smith. This means your XML and its DTD/Schema are backward compatible with older XSLT.

Additional information

Further additional information


Rate this article on a scale of 1 to 10 (0 votes, average 0)

Your vote :  

<< reBloggerSEO >>





Leave a comment for this article
Your name
Your email (optional)
Your comment
Optional: Upload an attachment
Enter the code shown:

 
 

    Email TopXML