Hello,
We have a application where we have to count the length of the fieldcode text for which we are counting the text inside the InstrText tag which is working fine so far. But we are not able to calculate the fieldcode text of the internal hyperlink field. we using below code snippet to manually build instrText of the hyperlink field.
string HyperlinkFC = string.Empty;
if (element.Attributes().Any(a => a.Name.LocalName == “anchor”))
{
if (element.Attributes().Any(a => a.Name.LocalName == “anchor”))
{
string s = @”HYPERLINK \l”;
HyperlinkFC = string.Format(” {0} \”{1}\” “, s, element.Attribute(W.anchor).Value);
}
string fieldvalue = element.Elements(W.r).First() != null ? element.Elements(W.r).First().Value : string.Empty;
fieldCodeText.Append(HyperlinkFC);
}
Above code is working fine for some cases like below:
{HYPERLINK \l “_Toc165886552”}
But it is failing for some cases where there is a single character white space inside the Hypertext fieldcode in the begining and end as below
{ HYPERLINK \l “_Toc165886552” }
Please help it is very urgent.
Thanks in advance,
Manu