I am working on the Tom.Net API in SDL Tridion 2011 SP1. I am trying to get the "source" part of XhtmlField.
My source looks like this.
<Content>
<text>
<p xmlns="http://www.w3.org/1999/xhtml">hello all<strong>
<a id="ID1" href="#" name="ZZZ">Name</a>
</strong></p>
</text>
</Content>
I want to get the source of this text field and process the tags with the name a.
I tried the following:
ItemFields content = new ItemFields(sourcecomp.Content, sourcecomp.Schema);
XhtmlField textValuesss = (XhtmlField)content["text"];
XmlElement textxmlelement = textValuesss.Definition.ExtensionXml;
Response.Write("<BR>" + "count:" + textxmlelement.ChildNodes.Count);
for (int i = 0; i < textxmlelement.ChildNodes.Count; i++)
{
Response.Write("<BR>" + "nodes" + textxmlelement.ChildNodes[i].Name);
}
XmlNodeList nodeswithnameA = textxmlelement.GetElementsByTagName("a");
foreach (XmlNode eachNode in nodeswithnameA)
{
string value = eachNode.Attributes["id"].Value;
Response.Write("<BR>" + "idValue" + value);
}
I do not get any output. Moreover, I get the score as zero.
The output I received is:
quantity: 0
Although I have several child tags in the field, I donβt understand why 0 comes like Count.
Can anyone suggest the necessary changes.
Thank.
source
share