Getting zero elements with xmldocument.selectnodes
-
Hi. I have an xml document that im loading to the xmldocument class. After loading i can see in the innerXML property the xml text. Using the FirstChild propery gets me the "html" node. But when im trying to get nodes , any nodes including the "html" node using the "selectNodes" or "selectSingleNode" using XPath, i always get zero nodes; Example doc.SelectSingleNode("//html") . dosent return any node. the xml code looks like that :
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="verify-v1" content="k1br6sikEUd0k3G96/qOGGoQOfCbjtZUn+oT10GDsHc=" /><meta name="keywords" content="lyric, lyrics, song, music, song lyrics, music lyrics" /><meta name="description" content="Lyrics.com is a music community with the largest searchable lyrics database." /><meta name="robots" content="all" /><meta name="server" content="10.1.10.2" /><title>Lyrics.com - your music community with the largest searchable lyrics database.</title><script type="text/javascript" src="http://www.lyrics.com/js/prototype.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/overlay.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/common.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/lyrics.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/users.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/scriptaculous.js"></script><link href="/stylesheets/main.v2.css" rel="stylesheet" type="text/css" /><!--[if IE 7]><link href="/stylesheets/ie7.css" type="text/css" rel="stylesheet" /><![endif]--><!--[if lt IE 7.]><script defer type="text/javascript" src="/js/pngfix.js"></script><![endif]--><!--[if IE 6]><link href="/stylesheets/ie6.css" type="text/css" rel="stylesheet" /><script src="/js/ie6.js" type="text/javascript"></script><script src="/js/pngfix.js" type="text/javascript"></script><![endif]--><!-- --><script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js"></script> . . . .
Any ideas why? Thanks -
Hi. I have an xml document that im loading to the xmldocument class. After loading i can see in the innerXML property the xml text. Using the FirstChild propery gets me the "html" node. But when im trying to get nodes , any nodes including the "html" node using the "selectNodes" or "selectSingleNode" using XPath, i always get zero nodes; Example doc.SelectSingleNode("//html") . dosent return any node. the xml code looks like that :
<html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><meta name="verify-v1" content="k1br6sikEUd0k3G96/qOGGoQOfCbjtZUn+oT10GDsHc=" /><meta name="keywords" content="lyric, lyrics, song, music, song lyrics, music lyrics" /><meta name="description" content="Lyrics.com is a music community with the largest searchable lyrics database." /><meta name="robots" content="all" /><meta name="server" content="10.1.10.2" /><title>Lyrics.com - your music community with the largest searchable lyrics database.</title><script type="text/javascript" src="http://www.lyrics.com/js/prototype.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/overlay.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/common.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/lyrics.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/users.js"></script><script type="text/javascript" src="http://www.lyrics.com/js/scriptaculous.js"></script><link href="/stylesheets/main.v2.css" rel="stylesheet" type="text/css" /><!--[if IE 7]><link href="/stylesheets/ie7.css" type="text/css" rel="stylesheet" /><![endif]--><!--[if lt IE 7.]><script defer type="text/javascript" src="/js/pngfix.js"></script><![endif]--><!--[if IE 6]><link href="/stylesheets/ie6.css" type="text/css" rel="stylesheet" /><script src="/js/ie6.js" type="text/javascript"></script><script src="/js/pngfix.js" type="text/javascript"></script><![endif]--><!-- --><script type="text/javascript" src="http://partner.googleadservices.com/gampad/google_service.js"></script> . . . .
Any ideas why? Thanksyou need to consider namespace when dealing with this XML. check out this link for a better explanation: http://weblogs.asp.net/wallen/archive/2003/04/02/4725.aspx