D
Dariusz Tomoñ
Hi,
I have got xml document with CDATA sections containing special characters
like links to images. All Iwant is to display the content in my div
section.
I tried like this:
protected void Button2_Click(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("http://www.e-biznes.pl/out/rss-ebiz-full-html.xml");
XPathNavigator xpathNav = xmlDoc.CreateNavigator();
xpathNav.MoveToRoot();
RecurseNavNodes(xpathNav);
}
public void RecurseNavNodes(XPathNavigator node)
{
//start recursive loop with level 0
RecurseNavNodes(node, 0);
}
public void RecurseNavNodes(XPathNavigator node, int level)
{
if (node.Name == "item")
{
ItemXmlXPathNavigator (node);
}
string s = null;
s = string.Format("{0} <b>Type:</b>{1} <b>Name:</b>{2} <b>Attr:</b> ", new
string('-', level), node.NodeType, node.Name);
if (node.InnerXml.Length > 0 && level>0)
{
s += "</BR>" + node.InnerXml;
}
if (node.HasChildren)
{
node.MoveToFirstChild();
do
{
RecurseNavNodes(node, level + 1);
} while (node.MoveToNext()); node.MoveToParent();
}
}
public void ItemXmlXPathNavigator(XPathNavigator node)
{
if (node.HasChildren)
{
node.MoveToFirstChild();
do
{
if (node.Name == "title")
{
lbl.Text += node.InnerXml + "<BR/><BR/>";
}
if (node.Name == "description")
{
//XmlCDataSection cdatas = node.;
//cdatas.InnerXml = node.InnerXml;
string zawartosc = node.InnerXml;
zawartosc = zawartosc.Replace("<", "<");
zawartosc = zawartosc.Replace(">", ">");
lbl.Text += "<font color='blue'>" + zawartosc + "</font>" + "<BR/><BR/>";
}
} while (node.MoveToNext()); node.MoveToParent();
}
}
But I got escaped characters instead of html tags.
I have got html tags like <img src=.... oraz embadded swfs, so I need to
retrieve CDATA section in other way than normal
node.InnerXml
Can you provide me a snippet of a code.
Thank you in advance.
Darek T.
I have got xml document with CDATA sections containing special characters
like links to images. All Iwant is to display the content in my div
section.
I tried like this:
protected void Button2_Click(object sender, EventArgs e)
{
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load("http://www.e-biznes.pl/out/rss-ebiz-full-html.xml");
XPathNavigator xpathNav = xmlDoc.CreateNavigator();
xpathNav.MoveToRoot();
RecurseNavNodes(xpathNav);
}
public void RecurseNavNodes(XPathNavigator node)
{
//start recursive loop with level 0
RecurseNavNodes(node, 0);
}
public void RecurseNavNodes(XPathNavigator node, int level)
{
if (node.Name == "item")
{
ItemXmlXPathNavigator (node);
}
string s = null;
s = string.Format("{0} <b>Type:</b>{1} <b>Name:</b>{2} <b>Attr:</b> ", new
string('-', level), node.NodeType, node.Name);
if (node.InnerXml.Length > 0 && level>0)
{
s += "</BR>" + node.InnerXml;
}
if (node.HasChildren)
{
node.MoveToFirstChild();
do
{
RecurseNavNodes(node, level + 1);
} while (node.MoveToNext()); node.MoveToParent();
}
}
public void ItemXmlXPathNavigator(XPathNavigator node)
{
if (node.HasChildren)
{
node.MoveToFirstChild();
do
{
if (node.Name == "title")
{
lbl.Text += node.InnerXml + "<BR/><BR/>";
}
if (node.Name == "description")
{
//XmlCDataSection cdatas = node.;
//cdatas.InnerXml = node.InnerXml;
string zawartosc = node.InnerXml;
zawartosc = zawartosc.Replace("<", "<");
zawartosc = zawartosc.Replace(">", ">");
lbl.Text += "<font color='blue'>" + zawartosc + "</font>" + "<BR/><BR/>";
}
} while (node.MoveToNext()); node.MoveToParent();
}
}
But I got escaped characters instead of html tags.
I have got html tags like <img src=.... oraz embadded swfs, so I need to
retrieve CDATA section in other way than normal
node.InnerXml
Can you provide me a snippet of a code.
Thank you in advance.
Darek T.