Hi, I've got an XML file with one <title> and one <link> attribute.
What I want to do is implement a hyperlink with the name of the <title> element and whose NavigateUrl property is set to the <link> element.
For an unusual reason, the hyperlink never appears but, when debugged, both items from the XML file are appended to the hyperlink. What have I done wrong?
Cheers,
Matt
What I want to do is implement a hyperlink with the name of the <title> element and whose NavigateUrl property is set to the <link> element.
For an unusual reason, the hyperlink never appears but, when debugged, both items from the XML file are appended to the hyperlink. What have I done wrong?
Cheers,
Matt
Code:
private void ReadXML()
{
using (StreamReader sr = File.OpenText(xmlFile))
{
while (!sr.EndOfStream && sr.Read() > 0)
{
string line = sr.ReadLine();
if (line.Contains("<title>"))
{
// read until we reach </title>
HyperLink4.Text = line.Replace("<title>", ""); // read until <title>
HyperLink4.Text = line.Replace("</title>", ""); // read until <title>
}
// link should follow straight after
else if (line.Contains("<link>"))
{
HyperLink4.NavigateUrl = line.Replace("<link>", "");
HyperLink4.NavigateUrl = line.Replace("</link>", ""); // read until <title>
}
}
}
}
Comment