How to get text of header and footer using C#

I am trying to find a specific string of text in the header that I want to replace. In my document there seems to be more than one header in the FirstSection.HeadersFooters collection with three of them all listed as Story = HeaderPrimary but I am only getting the text from the first one of the HeaderPrimary which only has “/r” text. How can I get either all the text of each HeaderPrimary or search for the string I’m looking for?

@johnmann04

HeaderFooterCollection class provides typed access to HeaderFooter nodes of a Section. There can be maximum of one HeaderFooter of each HeaderFooterType per Section.

Could you please ZIP and attach your input and expected output documents? We will then provide you more information about your query.

Thanks for the clarification. I see the issue now…