Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > xmlns attribute???

Reply
Thread Tools

xmlns attribute???

 
 
John
Guest
Posts: n/a
 
      03-04-2008
HI,

I have a xml document containing a xmlns attribute.

xmlns="urn:schemas-microsoft-comAG:MyList-application-block:v2:list">

I am using C# and statement xmlDoc.SelectNodes("//list") returns me nothing.

However, if I remove that attribute, this C# statement works.

Please help me understand this attribute.

Thanks.



 
Reply With Quote
 
 
 
 
Anthony Jones
Guest
Posts: n/a
 
      03-04-2008

"John" <(E-Mail Removed)> wrote in message
news(E-Mail Removed)...
> HI,
>
> I have a xml document containing a xmlns attribute.
>
> xmlns="urn:schemas-microsoft-comAG:MyList-application-block:v2:list">
>
> I am using C# and statement xmlDoc.SelectNodes("//list") returns me

nothing.
>
> However, if I remove that attribute, this C# statement works.
>
> Please help me understand this attribute.
>




You need to use the XmlNamespaceManager

XmlNamespaceManager nm = new XmlNamespaceManager(xmlDoc.NameTable);

nm.AddNamespace("a",
"urn:schemas-microsoft-comAG:MyList-application-block:v2:list");

XmlNodeList nl = xmlDoc.SelectNodes("//a:list", nm);




--
Anthony Jones - MVP ASP/ASP.NET


 
Reply With Quote
 
 
 
 
John
Guest
Posts: n/a
 
      03-05-2008
Thank you very much.

"Anthony Jones" wrote:

>
> "John" <(E-Mail Removed)> wrote in message
> news(E-Mail Removed)...
> > HI,
> >
> > I have a xml document containing a xmlns attribute.
> >
> > xmlns="urn:schemas-microsoft-comAG:MyList-application-block:v2:list">
> >
> > I am using C# and statement xmlDoc.SelectNodes("//list") returns me

> nothing.
> >
> > However, if I remove that attribute, this C# statement works.
> >
> > Please help me understand this attribute.
> >

>
>
>
> You need to use the XmlNamespaceManager
>
> XmlNamespaceManager nm = new XmlNamespaceManager(xmlDoc.NameTable);
>
> nm.AddNamespace("a",
> "urn:schemas-microsoft-comAG:MyList-application-block:v2:list");
>
> XmlNodeList nl = xmlDoc.SelectNodes("//a:list", nm);
>
>
>
>
> --
> Anthony Jones - MVP ASP/ASP.NET
>
>
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
What does xmlns:xsi and xmlns:xsd attributes mean? afshar XML 3 05-19-2010 02:16 AM
xmlns:SOAP-ENC, xmlns:xsd required? chris.stromberger@gmail.com XML 0 10-26-2005 02:48 PM
Unrecognized attribute 'xmlns'. john1001 ASP .Net 6 10-15-2005 12:32 PM
Ignoreing xmlns in XML document Maziar Aflatoun ASP .Net 0 08-25-2005 03:39 PM
ASP.NET xmlns=''> was not expected problem pei_world ASP .Net 4 06-15-2004 01:17 PM



Advertisments