Is this what you are looking for?
<a href="/XYZ/mypage.html">Text</a>
This is because URLs which start with a forward-slash (/) are called 'absolute paths', and refer to the root, i.e. relative to mysite.com
Alternatively, if you want to affect the next directory up only, you can use the following:
<a href="../XYZ/mypage.html">Text</a>
This is because .. refers to the parent directory. So if you had a page at example.com/folder1/ABC/mypage.html and you wanted that page to link to example.com/newpages/XYZ/mypage.html, you could do:
<a href="../../newpages/XYZ/mypage.html">Text</a>
There are lots of examples and tutorials online, e.g. https://www.w3.org/TR/WD-html40-970917/htmlweb.html