why not just AD.marshallAsAttribute/marshallAsElement()
and if you need special format just define custom marshaller on attribute, that would make parser/marshaller much cleaner