Hi all
I have the following xml file
In the long term there will be a lot more information and tags in this file. What I want to do is to be able to read the data from the text tag where the id of the data tag is equal to a value that I have specified.
Here is the code that I am using to access the xml file and read from it:
So my question is, how can I adjust the above vb.net code so that I could in one instance specify that I want to access the text where the id of the data tag is "Home2"
I have the following xml file
Code:
<?xml version="1.0" encoding="utf-8" ?>
<root>
<data id="Home1">
<text>
<![CDATA[
Using your web browser or mobile phone, Clubtext allows you tosend SMS <br>
text messages to your customers, teams, staff, or club members in an easy<br>
to use cost effective manner.
<p>Clubtext includes an administrative set of features to allow you to <br>
manage customer/membership details and history.]]></text>
</data>
<data id="Home2">
<text>
<![CDATA[
This is the data that belongs to home 2. Hello world, how are you today?
]]>
</text>
</data>
</root>
In the long term there will be a lot more information and tags in this file. What I want to do is to be able to read the data from the text tag where the id of the data tag is equal to a value that I have specified.
Here is the code that I am using to access the xml file and read from it:
Code:
Private Sub GenerateXMLMessageBody()
Dim m_xmlr As XmlTextReader
m_xmlr = New XmlTextReader("C:\Inetpub\wwwroot\SuretxtWebSolution\Suretxt\InformationContent.xml")
m_xmlr.WhitespaceHandling = WhitespaceHandling.None
m_xmlr.Read()
m_xmlr.Read()
Load the Loop
While Not m_xmlr.EOF
Go to the name tag
m_xmlr.Read()
if not start element exit while loop
If Not m_xmlr.IsStartElement() Then
Exit While
End If
Get the Gender Attribute Value
Dim genderAttribute = m_xmlr.GetAttribute("id")
Read elements firstname and lastname
m_xmlr.Read()
main.InnerHtml = m_xmlr.ReadElementString("text").ToString
End While
close the reader
m_xmlr.Close()
End Sub
So my question is, how can I adjust the above vb.net code so that I could in one instance specify that I want to access the text where the id of the data tag is "Home2"