private SbdReader(XmlTextReader reader) { this.reader = reader; try { // First element, SBD expected. while (reader.NodeType != XmlNodeType.Element) { reader.Read(); } if (!reader.IsElement(Ns.QNAME_SBD)) { throw new SbdhException("Element 'StandardBusinessDocument' not found as first element."); } // Read header reader.ReadToNextElement(); if (!reader.IsElement(Ns.QNAME_SBDH)) { throw new SbdhException( "Element 'StandardBusinessDocumentHeader' not found as first element in 'StandardBusinessDocument'."); } this.Header = SbdhReader.Read(reader); // Go to payload var found = reader.ReadToNextElement(); if (!found) { throw new SbdhException("Payload not found."); } } catch (Exception e) { throw new SbdhException(e.Message, e); } }