Small function for getting character value
The easiest code to maintain is code that doesn't exist.  For parsing XML, use an XML-parsing library, preferably with XPath support.  Sometimes it might be justified to whip up your own code to extract values from XML, but it clearly does not make sense in this case.  Not only is the code ugly by your own admission, low-level string- and memory-manipulation also distracts you from thinking about the big picture.  Furthermore, your code will be less robust than a proper XML parser, and it will fail if the text is encoded in a semantically equivalent variant (for example, if a value is escaped).