Estoy trabajando en las API de Tom.Net en SDL Tridion 2011 SP1. Estoy tratando de recuperar la parte "fuente" de XhtmlField.Obteniendo el XMLsource completo para un campo Xhtml usando las API de Tom.Net en SDL Tridion 2011 SP1
Mi fuente se parece a esto.
<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>
quiero conseguir la fuente de este campo "texto" y procesar las etiquetas con el nombre a
.
me trataron siguiente:
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);
}
//get all the nodes with the name a
XmlNodeList nodeswithnameA = textxmlelement.GetElementsByTagName("a");
foreach (XmlNode eachNode in nodeswithnameA)
{
//get the value at the attribute "id" of node "a"
string value = eachNode.Attributes["id"].Value;
Response.Write("<BR>" + "idValue" + value);
}
No estoy recibiendo ninguna salida. Más de lo que estoy recibiendo el recuento como cero.
salida que tengo:
cuenta: 0
Aunque tengo algunas etiquetas hijo en el campo, no estoy recibiendo por qué 0 viene como Count
.
Puede sugerir la modificación necesaria.
Gracias.
Ha búsquedas de varias anclas, por lo que sería mejor .SelectNodes –
hecho(). El punto principal era utilizar XPath en lugar de pasar sobre nodos secundarios. –