473,400 Members | 2,163 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,400 software developers and data experts.

XmlDocument xmlns problem

1
Hi, the problem is:

XmlReader xmlReader = XmlReader.Create("D:\\temp\\Example.html");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
XmlNodeList list = xmlDoc.SelectNodes("/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>
Apr 2 '08 #1
1 1406
shweta123
692 Expert 512MB
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.SelectNodes("/html xmlns=http://www.w3.org/1999/xhtml/head/title");




Hi, the problem is:

XmlReader xmlReader = XmlReader.Create("D:\\temp\\Example.html");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.Load(xmlReader);
XmlNodeList list = xmlDoc.SelectNodes("/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>
Apr 2 '08 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Mark Jerde | last post by:
I've been looking through MSDN, books and googling for a couple hours but haven't found the solution yet. I'm using CSharp in VS .NET 2003. I'm trying to use XmlDocument to save XML files that...
4
by: David Grogan | last post by:
Hi, 2 questions.... 1. I'm parsing an XHTML document that contains both the default namespace (xmlns="http://www.w3.org/1999/xhtml") and a custom one (xmlns:r="...") - both of these being...
1
by: Richard | last post by:
Hi, I would like to strip all of the "xmlns" attributes out of an XmlDocument. I coded a function that recurses nodes and calls: XmlNode n = node.Attributes.RemoveNamedItem("xmlns"); After...
0
by: Mungo Jerrie | last post by:
Hi there I have a small problem with my namespaces: I would like to end up with this xml: <?xml version="1.0" encoding="ISO-8859-1"?> <Invoice...
0
by: saish | last post by:
Hello I am new to vb.net webservice. My requirement is to design a VB.net web service which will send and receive xml documents. The xml document send and received would be a very complex .xsd...
3
by: Andy Fish | last post by:
Hi, I am creating a new XmlDocument from scratch, but I can't see how I can make a namespace declaration and associate a prefix with it. For instance in the following example: XmlDocument doc...
3
by: Stuart Shay | last post by:
Hello All In the following XML Below which is a XMLDocument in my application. I want to remove the <extensions></extensions> Node completely. What is the best way to do this, my files are...
0
by: Ewan Fairweather | last post by:
Hi, I'm generating the below XML in c# for an asp.net application When i've generated this XML the <LaboratoryDetails xmlns=""> element has a blank xmlns set. How do i either a) remove this...
1
by: Ewan Fairweather | last post by:
Hi, I'm generating the below XML in c# for an asp.net application When i've generated this XML the <LaboratoryDetails xmlns=""> element has a blank xmlns set. How do i either a) remove this...
0
by: Baren | last post by:
Hi! All, I am facing a problem while creating a XMLDocument from a XmlSerialized Object . Here is my code and the error I am getting. Can anyone help me out. Check the attribute value of EmpID...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.