这是我的代码样式:
这是可行的代码:(感谢大家的建议...没有你们就无法完成!) Spokane-Dude
这是我的代码样式:
case "Creator":
br.Read();
br.MoveToContent(); // gives the content of the role
tbComposer.Text = br.Value;
br.Read();
br.MoveToContent(); // gives the content of the role
tbConductor.Text = br.Value;
br.Read();
br.MoveToContent(); // gives the content of the role
tbOrchestra.Text = br.Value;
break;
这是可行的代码:(感谢大家的建议...没有你们就无法完成!) Spokane-Dude
case "Creator":
br.MoveToFirstAttribute();
if (br.Value == "Composer") {
br.Read();
tbComposer.Text = br.Value;
}
if (br.Value == "Conductor") {
br.Read();
tbConductor.Text = br.Value;
}
if (br.Value == "Orchestra") {
br.Read();
tbOrchestra.Text = br.Value;
}
break;
这是我的XML的样子:
<ItemLookupResponse>
<OperationRequest/>
<Items>
<Request/>
<Item>
<ItemAttributes>
<Binding>Audio CD</Binding>
<CatalogNumberList>
<CatalogNumberListElement>43850</CatalogNumberListElement>
</CatalogNumberList>
<Creator Role="Composer">Gioachino Rossini</Creator>
<Creator Role="Conductor">Riccardo Chailly</Creator>
<Creator Role="Orchestra">National Philharmonic Orchestra</Creator>
</ItemAttributes>
</Item>
</Items>
</ItemLookupResponse>
我需要知道我是否正在读取元素 Creator Role="Composer" 或 Creator Role="Conductor" 等等。
因此,使用 XMLTextReader,我如何确定元素文本是什么?