Hyperlink fieldcode

Home Forums WordprocessingML Hyperlink fieldcode

Tagged: 

This topic contains 3 replies, has 3 voices, and was last updated by  Myname 5 years, 6 months ago.

Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #4041

    Manu_TR
    Participant

    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

    #4075

    Eric White
    Keymaster

    Hi Manu,

    The exact format of the text of field codes is defined in the Open XML standard. You must be prepared for those beginning and ending spaces.

    I believe that there is a grammar for the text of fields, if I remember correctly, so should be possible to build a small parser for it.

    -Eric

    #4076

    Manu_TR
    Participant

    Thanks you very much Eric,

    Could you please help me to create that parser, it will be very helpful.

    Thanks
    Manu

    #7656

    Myname
    Participant

    Here is a good persuasive essay writing guide for you https://pro-essay-writer.com/blog/persuasive-essay. You can write it with your own hands.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic.