XmlDocument xmlns problem

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • neuron
    New Member
    • Apr 2008
    • 1

    XmlDocument xmlns problem

    Hi, the problem is:

    XmlReader xmlReader = XmlReader.Creat e("D:\\temp\\Ex ample.html");
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(xml Reader);
    XmlNodeList list = xmlDoc.SelectNo des("/html/head/title");

    after this... list.Count is 0, but when I delete xmlns attribute (Example2.html, list.Count is 1...
    but I want list.Count == 1 result for Example.html, too ...so what I have to do ?

    Example.html:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>sa</title>
    </head>
    <body>
    bbbb
    </body>
    </html>

    Example2.html:
    <html>
    <head>
    <title>sa</title>
    </head>
    <body>
    bbbb
    </body>
    </html>
  • shweta123
    Recognized Expert Contributor
    • Nov 2006
    • 692

    #2
    Hi,

    I think ,for getting list.count =1 in Example.html, you have to change the search query in the SelectNodes statement.

    e.g. You can write it like this :


    XmlNodeList list = xmlDoc.SelectNo des("/html xmlns=http://www.w3.org/1999/xhtml/head/title");




    Originally posted by neuron
    Hi, the problem is:

    XmlReader xmlReader = XmlReader.Creat e("D:\\temp\\Ex ample.html");
    XmlDocument xmlDoc = new XmlDocument();
    xmlDoc.Load(xml Reader);
    XmlNodeList list = xmlDoc.SelectNo des("/html/head/title");

    after this... list.Count is 0, but when I delete xmlns attribute (Example2.html, list.Count is 1...
    but I want list.Count == 1 result for Example.html, too ...so what I have to do ?

    Example.html:
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head>
    <title>sa</title>
    </head>
    <body>
    bbbb
    </body>
    </html>

    Example2.html:
    <html>
    <head>
    <title>sa</title>
    </head>
    <body>
    bbbb
    </body>
    </html>

    Comment

    Working...