Get values from file

  • Thread starter Thread starter shapper
  • Start date Start date
S

shapper

Hello,

I have a XML (Keywords.xml) file as follows:

<objective name="english">
<keyword>english</keyword>
<keyword>england</keyword>
</objective>

I want to create a string from all the keywords for a given objective.
The steps would be:

Get ALL Keywords for Name = <Something>

MyString = "Keyword1, Keyword2, Keyword3"

Thanks,

Miguel
 
Hi,
Hello,

I have a XML (Keywords.xml) file as follows:

<objective name="english">
<keyword>english</keyword>
<keyword>england</keyword>
</objective>

I want to create a string from all the keywords for a given objective.
The steps would be:

Get ALL Keywords for Name = <Something>

MyString = "Keyword1, Keyword2, Keyword3"

Thanks,

Miguel

What code do you have already?

Usually, when you ask a question on a newsgroup, you're expected to have
tried by yourself first.

Here's a starter: You need to load the XML file in a XmlDocument
http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.aspx

Once loaded, you access the elements using GetElementsByTagName
http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.getelementsbytagname.aspx

For the "objective" tag, I would rather use an "ID" and not a "name",
because then you can use the method GetElementById to access the desired
element faster.
http://msdn2.microsoft.com/en-us/library/system.xml.xmldocument.getelementbyid.aspx

HTH,
Laurent
 
Back
Top