• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

How to parse the XML values inside the attribute

 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
All,
I have a difficulty to figure this one out. Basically I am interested to parse the attribute value of MsgXMLStream for msgdata element which is "New"
Note:
the attribute for MsgXMLStream is
<msgdata>New</msgdata>
Thank you for your assistance.
Greatly appreciated,
David Sundo
-----------(I make an xml file called "test.xml")
<?xml version="1.0"?>
<?xml-stylesheet type="text/xsl" href="test.xsl"?>
<rs>
<z MsgID_PK='79' MsgXMLStream='<msgdata>New<msgdata>'/>
</rs>
------------Test.xsl--------------------
<?xml version="1.0"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl">
<xsl:template match="/">
<xsl:apply-templates select="//rs" />
</xsl:template>
<xsl:template match="//rs">
<xsl:for-each select="z">
<xsl:for-each select="@MsgXMLStream">
<xsl:value-of select="*"/>
</xsl:for-each>
</xsl:for-each>
</xsl:template>
</xsl:stylesheet>
 
Author and all-around good cowpoke
Posts: 13078
6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
As you have undoubtedly found out, parsers treat the whole attribute as a text string. You are going to have to parse the string yourself.
Finding the last position of "<" and first position of ">" will bracket the contents.
Bill
 
Ranch Hand
Posts: 1056
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is not well-formed XML because you cannot have the character < in an attribute value. You will need to change it to &lt; (While you're at it, you should also change > to &gt; )
[ November 25, 2002: Message edited by: Ron Newman ]
 
Those cherries would go best on cherry cheesecake. Don't put those cherries on this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic