1

.vsdx ファイルを読み取る C# アプリを作成しようとしています。以下の XML は、私のファイルの 1 つのページです。and属性Shapeを持つ要素はごくわずかです。これがなぜなのか、またはどのように修正できるのか誰にもわかりますか? 属性を持たない下のすべての要素はライフラインにする必要があります。NameNameUShapeNameObject

<?xml version="1.0" encoding="UTF-8"?>
-<PageContents xml:space="preserve" xmlns:r="http://schemas.openxmlformats.org/officeDocument/2006/relationships" xmlns="http://schemas.microsoft.com/office/visio/2012/main">
-<Shapes>
+<Shape Master="7" Type="Group" Name="Object lifeline" NameU="Object lifeline" ID="1">
+<Shape Master="7" Type="Group" ID="6">
+<Shape Master="7" Type="Group" ID="11">
+<Shape Master="7" Type="Group" ID="16">
+<Shape Master="7" Type="Group" ID="21">
+<Shape Master="7" Type="Group" ID="26">
+<Shape Master="7" Type="Group" ID="31">
+<Shape Master="8" Type="Shape" Name="Message" NameU="Message" ID="36">
+<Shape Master="8" Type="Shape" ID="37">
+<Shape Master="9" Type="Shape" Name="Return Message" NameU="Return Message" ID="38">
+<Shape Master="7" Type="Group" Name="Object lifeline.39" NameU="Object lifeline.39" ID="39">
+<Shape Master="7" Type="Group" Name="Object lifeline.44" NameU="Object lifeline.44" ID="44">
+<Shape Master="8" Type="Shape" ID="49">
+<Shape Master="8" Type="Shape" ID="51">
+<Shape Master="9" Type="Shape" ID="52">
+<Shape Master="11" Type="Shape" Name="Activation" NameU="Activation" ID="53">
+<Shape Master="8" Type="Shape" ID="54">
4

1 に答える 1

0
var xDoc = XDocument.Load(path);
var elements = (from e in xDoc.Descendants("Shape")
                    where (string)e.Attribute("Name") == null
                      select e).ToList();
foreach (var item in elements)
{
    item.Add(new XAttribute("Name", "Object lifeline");
}
xDoc.Save(path);
于 2014-01-08T02:45:42.313 に答える