MR wrote:
i apologize in advance for what i know is a simple question, but i am being
exposed to the first time to xml.
considering the following string that i receive:
<BusinessEntity xsi:type="DynamicEntity" Name="contact"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://schemas.microsoft.com/crm/2006/WebServices">
<Properties>
<Property xsi:type="KeyProperty" Name="contactid">
<Value>{80FB716B-B189-DA11-84BD-0003FFC6732A}</Value>
</Property>
<Property xsi:type="StringProperty" Name="new_duplicateid">
<Value>8e0c0022-2078-4017-9630-6453e80695c0</Value>
</Property>
</Properties>
</BusinessEntity
How do i parse the values of contactid and new_duplicateid?
Parsing the document is done by a parser, either standalone or embedded
in your XML software, and on its own it won't achieve anything other
than to confirm that the document is or isn't well-formed or valid.
When connected to processing software, a parser passes the document
structure and content in memory to the application to do whatever it's
written to do.
I'm assuming that you actually mean you want to retrieve the value of
the Name attribute of the Property elements. Correct me if I'm wrong.
(Parsing an attribute *value* may be outside the scope of XML, although
it can often be configured in the Schema or DTD.)
In XSLT, the most common XML transformation language, the value of an
attribute can be retrieved in several ways depending on what you want to
do with it. For example to see in the above example if the two values
of Name were the same of different, you might use
<xsl:template match="Properties">
<xsl:choose>
<xsl:when test="Property[1]/@Name=Property[2]/@Name">
...do something when they are the same...
</xsl:when>
<xsl:otherwise>
...do something when they are different...
</xsl:otherwise>
</xsl:choose>
</xsl:templates>
But YMMV and a lot will depend on what you want to do, and the
environment you want to do it in (eg .NET).
///Peter
--
XML FAQ:
http://xml.silmaril.ie/