我正在制作一个 docx 阅读器(libopc 和 C++),当我想从 theme1.xml 获取次要和主要字体时遇到问题。问题是我不知道如何在没有它的情况下为属性编写命名空间:
<a:latin typeface="Calibri"/>
我尝试过:
mce_start_attribute(&reader, _X(""), _X("typeface")) {//type
_majorFont = (char*) xmlTextReaderConstValue(reader.reader);
}mce_end_attribute(&reader);
和:
mce_start_attribute(&reader, _X("http://www.3w.org/2000/xmlns"), _X("typeface")) {//type
_majorFont = (char*) xmlTextReaderConstValue(reader.reader);
}mce_end_attribute(&reader);
我得到了相同的结果:什么也没有。
任何建议。 提前致谢。
最佳答案
我自己回答。 检查libopc源代码后,解决方案是将mce_start_attribute宏中的命名空间值设置为NULL:
mce_start_attribute(&reader, NULL, _X("typeface")) {//type
_majorFont = (char*) xmlTextReaderConstValue(reader.reader);
}mce_end_attribute(&reader);
关于c++ - 从 .docx 读取 theme1.xml,没有命名空间的属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14382319/