Problem reading XML
-
I have a simple xml file that displays a card file like in a Library. Each card has only one attribute, the index number. The cards are displayed in a treeview and when a use selects one I need to display the card's content in a window. The problem is that I don't know how to access a single element by referencing the attribute "number". Xml file: This is the front of card 1. This is the back of card 1. This is the front of card 2. This is the back of card 2. ... etc. Thanks, Mark
-
I have a simple xml file that displays a card file like in a Library. Each card has only one attribute, the index number. The cards are displayed in a treeview and when a use selects one I need to display the card's content in a window. The problem is that I don't know how to access a single element by referencing the attribute "number". Xml file: This is the front of card 1. This is the back of card 1. This is the front of card 2. This is the back of card 2. ... etc. Thanks, Mark
@ is the symbol used for attributes in an XPath. I think it's someting like "/cardfile/card[@number='0']" The W3C website has excellent XPath tutorials on it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
-
I have a simple xml file that displays a card file like in a Library. Each card has only one attribute, the index number. The cards are displayed in a treeview and when a use selects one I need to display the card's content in a window. The problem is that I don't know how to access a single element by referencing the attribute "number". Xml file: This is the front of card 1. This is the back of card 1. This is the front of card 2. This is the back of card 2. ... etc. Thanks, Mark
It seems you are new to XML, so I don't suggest using low-level code, there is a easy to use System.Configuration namespace out there in MSDN Library, have a look at it. 1) Create a custom ConfigurationSectionGroup called cardfile 2) Create a custom ConfigutaionSection called card number 3) Create a custom ConfigurationElementCollection to store your front(s) 4) Create a custom ConfigurationElement called front You can find all the source code examples for the steps 1->4 in MSDN library and in internet This is the link: ms-help://MS.VSCC.v80/MS.MSDN.v80/MS.NETDEVFX.v20.en/cpref4/html/T_System_Configuration_ConfigurationElement.htm OR Look for: 1) ConfigurationElemnt class in MSDN Library Index Tab filtered by Visual C# 2) Select "about ConfigurationElement class" and there you are ;) Hope this helps...
-
@ is the symbol used for attributes in an XPath. I think it's someting like "/cardfile/card[@number='0']" The W3C website has excellent XPath tutorials on it.
Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )