Xml 태그 이름과 해당 값을 보유하기 위해 두 개의 요소가있는 구조체를 Array에 유지하려고합니다.구조체를 포함하는 배열을 만들려고합니까?
나는이 같은 작업 배열을 가지고 싶다 :
MyArrayStruct[Count].TagName = "Bla Bla";
MyArrayStruct[Count].TagValue = "Bla Bla Bla";
는 일부는이 작업을 진행하는 데 도움이 시겠어요. 구조체는 내가 원하는 것처럼 작업을 가지도록
public struct TagContents
{
String TagName;
String TagValue;
};
나는 내가 그것을 주석 밖으로 코드처럼 작동하는 것을, 배열을 선언하는 문제가 있어요.
public void LoadXML()
{
if (File.Exists("Data.xml"))
{
//Readin XML
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("Data.xml");
XmlNodeList dataNodes = xmlDoc.SelectNodes("//FieldData");
//Count the nodes
int Max = 0;
foreach (XmlNode node in dataNodes)
{
Max = Max + 1;
}
int Count = 0;
//TagContents MyXmlPointer = new TagContents();
// MyXmlPointer[] ArrayNode;
// ArrayNode = new MyXmlPointer[Max];
foreach (XmlNode node in dataNodes)
{
// ArrayNode[Count].TagName =node.SelectSingleNode("Have not found what to put here yet but will get there").Name;
// ArrayNode[Count].TagValue =node.SelectSingleNode("Have not found what to put here yet but will get there").InnerText;
}
}
else
{
MessageBox.Show("Could not find file Data.xml");
}
}
정확하게 작동하지 않는거야? – waldrumpus
내가하고 싶은 부분을 주석으로 처리했지만 작동하지 않는다. – Pomster