MOBI_RET mobi_xml_write_item(xmlTextWriterPtr writer, const char *id, const char *href, const char *media_type) {
    int xml_ret;
    xml_ret = xmlTextWriterStartElement(writer, BAD_CAST "item");
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "id", BAD_CAST id);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "href", BAD_CAST href);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "media-type", BAD_CAST media_type);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterEndElement(writer);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    return MOBI_SUCCESS;
}
MOBI_RET mobi_xml_write_item(xmlTextWriterPtr writer, const char *id, const char *href, const char *media_type) {
    int xml_ret;
    xml_ret = xmlTextWriterStartElement(writer, BAD_CAST "item");
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "id", BAD_CAST id);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "href", BAD_CAST href);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterWriteAttribute(writer, BAD_CAST "media-type", BAD_CAST media_type);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    xml_ret = xmlTextWriterEndElement(writer);
    if (xml_ret < 0) {
        debug_print("XML error: %i (item id: %s)\n", xml_ret, id);
        return MOBI_XML_ERR;
    }
    return MOBI_SUCCESS;
}