我正在尝试使用OpenXML在PowerPoint演示文稿中遍历图像。OpenXML - 获取图像Alt文本标题
我已经制定了如何做到这一点。
我不会试图获取图像的Alt-文字标题....
这里是我的代码:
List<ImagePart> imageParts = new List<ImagePart>();
part.GetPartsOfType<ImagePart>(imageParts);
foreach (ImagePart imagePart in imageParts)
{
if (imagePart != null)
{
// Get the Relationship Id
string oldRelID = part.GetIdOfPart(imagePart);
// Get the Alt-Text Tile relating to this image
}
}
任何OpenXML的专家那里,可以给我一些指点?
感谢
UPDATE:
我曾尝试通过遍历XML但是当幻灯片上的多个图像我收到了标题为与图像不正确的值。
我想我需要能够使用ImagePart ID来,然后找到相应的标题
下面的代码获得冠军失灵......
foreach (ImagePart imagePart in imageParts)
{
string mapReference = "";
XmlNode thisNode = pictureNodeList[imageCounter];
foreach (XmlNode xmlnode in thisNode)
{
foreach (XmlNode xmlchildnode in xmlnode)
{
foreach (XmlAttribute att in xmlchildnode.Attributes)
{
if (att.Name == "title")
{
mapReference = att.Value;
imageCounter += 1;
}
}
}
}
}
这里是我如何找到这样的东西出来:创建你想要什么(有替代文字的图像)的文件,然后寻找它在XML文件中。这应该给你足够的信息来弄清楚如何访问所需的信息。 – helb