473,725 Members | 2,278 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

HOWTO Overcome missing namespace declaration in root node

I am having a problem deserializing XML when the root node is missing a
namespace declaration. My Type has an XmlTypeAttribut e with a namespace
defined. If I attempt to deserialize the XML, I get the dreaded

<elementname xmlns=''> was not expected

exception. If I comment out the XmlTypeAttribut e, it works just fine. Just
so you know, when I instantiate an instance of an XmlSerializer, I pass a
default namespace to the ctor. Unfortunately that doesn't seem to work.

So, how can I get the XmlSerializer to accept XML that is missing namespace
declarations?

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT
Nov 12 '05 #1
6 8345
David,

Can you post:

* The serialization class
* the tag of the root element, including all namespace definitions
* the line of code where you instantiate the XmlSerializer

--
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I am having a problem deserializing XML when the root node is missing a
namespace declaration. My Type has an XmlTypeAttribut e with a namespace
defined. If I attempt to deserialize the XML, I get the dreaded

<elementname xmlns=''> was not expected

exception. If I comment out the XmlTypeAttribut e, it works just fine. Just so you know, when I instantiate an instance of an XmlSerializer, I pass a
default namespace to the ctor. Unfortunately that doesn't seem to work.

So, how can I get the XmlSerializer to accept XML that is missing namespace declarations?

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT

Nov 12 '05 #2
Chris,
Look inline below:

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh Daily™
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:eN******** *****@TK2MSFTNG P12.phx.gbl...
David,

Can you post:

* The serialization class
[System.Xml.Seri alization.XmlTy peAttribute(Nam espace=Transfer Manifest.DEFAUL
T_NAMESPACE)]
[System.Xml.Seri alization.XmlRo otAttribute(Nam espace=Transfer Manifest.DEFAUL
T_NAMESPACE, IsNullable=fals e, ElementName="tr ansfermanifest" )]
public class TransferManifes t {

public const string DEFAULT_NAMESPA CE =
"http://codenoevil.com/TransferManifes t.xsd";

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "filelist")]
public FileList[] FileLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "folderlist ")]
public FolderList[] FolderLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "uploadinfo ")]
public UploadInfo[] UploadInfos;

#region XML (de)serializati on code
public static TransferManifes t ReadXml(string xml)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest));

xmlSerializer.U nknownNode+= new
XmlNodeEventHan dler(XmlSeriali zer_UnknownNode );
xmlSerializer.U nknownAttribute += new
XmlAttributeEve ntHandler(XmlSe rializer_Unknow nAttribute);

try
{
TransferManifes t transferManifes t =
(TransferManife st)xmlSerialize r.Deserialize(
new StringReader(xm l)
);

return transferManifes t;
}
catch(Exception ex)
{
throw new ApplicationExce ption("Transfer Manifest failed to deserialize: "
+ ex.Message, ex);
}
}

public static string WriteXml(Transf erManifest transferManifes t)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest), DEFAULT_NAMESPA CE);

StringWriter stringWriter = new StringWriter();

xmlSerializer.S erialize(string Writer, transferManifes t);

return stringWriter.To String();
}

private static void XmlSerializer_U nknownNode
(object sender, XmlNodeEventArg s e)
{
Debug.WriteLine ("Unknown Node:" + e.Name + "\t" + e.Text);
}

private static void XmlSerializer_U nknownAttribute
(object sender, XmlAttributeEve ntArgs e)
{
System.Xml.XmlA ttribute attr = e.Attr;
Debug.WriteLine ("Unknown attribute " +
attr.Name + "='" + attr.Value + "'");
}
#endregion
}

* the tag of the root element, including all namespace definitions
<transfermanife st>
* the line of code where you instantiate the XmlSerializer
Look inside the WriteXml() method above.

--
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I am having a problem deserializing XML when the root node is missing a
namespace declaration. My Type has an XmlTypeAttribut e with a namespace
defined. If I attempt to deserialize the XML, I get the dreaded

<elementname xmlns=''> was not expected

exception. If I comment out the XmlTypeAttribut e, it works just fine.

Just
so you know, when I instantiate an instance of an XmlSerializer, I pass a default namespace to the ctor. Unfortunately that doesn't seem to work.

So, how can I get the XmlSerializer to accept XML that is missing

namespace
declarations?

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT


Nov 12 '05 #3
David,

The code you posted works fine for me with this code:

TransferManifes t mfst = new TransferManifes t();
string xml = TransferManifes t.WriteXml( mfst );
mfst = TransferManifes t.ReadXml( xml );

but I removed the three array type properties

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "filelist")]
public FileList[] FileLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "folderlist ")]
public FolderList[] FolderLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "uploadinfo ")]
public UploadInfo[] UploadInfos;

because I didn't have the class definitions.

The root element

<transfermanife st>

you posted would not deserialize because it's missing the XML namespace that
you declared with the XmlRoot and XmlType attributes. The root element needs
a namespace declaration like this:

<transfermanife st xmlns=http://codenoevil.com/TransferManifes t.xsd>

which your code produces.

You could either post more code, or follow the instructions at [0] on how to
debug deserialization .

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Chris,
Look inline below:

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:eN******** *****@TK2MSFTNG P12.phx.gbl...
David,

Can you post:

* The serialization class

[System.Xml.Seri alization.XmlTy peAttribute(Nam espace=Transfer Manifest.DEFAUL T_NAMESPACE)]
[System.Xml.Seri alization.XmlRo otAttribute(Nam espace=Transfer Manifest.DEFAUL T_NAMESPACE, IsNullable=fals e, ElementName="tr ansfermanifest" )]
public class TransferManifes t {

public const string DEFAULT_NAMESPA CE =
"http://codenoevil.com/TransferManifes t.xsd";

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "filelist")]
public FileList[] FileLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "folderlist ")]
public FolderList[] FolderLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "uploadinfo ")]
public UploadInfo[] UploadInfos;

#region XML (de)serializati on code
public static TransferManifes t ReadXml(string xml)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest));

xmlSerializer.U nknownNode+= new
XmlNodeEventHan dler(XmlSeriali zer_UnknownNode );
xmlSerializer.U nknownAttribute += new
XmlAttributeEve ntHandler(XmlSe rializer_Unknow nAttribute);

try
{
TransferManifes t transferManifes t =
(TransferManife st)xmlSerialize r.Deserialize(
new StringReader(xm l)
);

return transferManifes t;
}
catch(Exception ex)
{
throw new ApplicationExce ption("Transfer Manifest failed to deserialize: " + ex.Message, ex);
}
}

public static string WriteXml(Transf erManifest transferManifes t)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest), DEFAULT_NAMESPA CE);

StringWriter stringWriter = new StringWriter();

xmlSerializer.S erialize(string Writer, transferManifes t);

return stringWriter.To String();
}

private static void XmlSerializer_U nknownNode
(object sender, XmlNodeEventArg s e)
{
Debug.WriteLine ("Unknown Node:" + e.Name + "\t" + e.Text);
}

private static void XmlSerializer_U nknownAttribute
(object sender, XmlAttributeEve ntArgs e)
{
System.Xml.XmlA ttribute attr = e.Attr;
Debug.WriteLine ("Unknown attribute " +
attr.Name + "='" + attr.Value + "'");
}
#endregion
}

* the tag of the root element, including all namespace definitions
<transfermanife st>
* the line of code where you instantiate the XmlSerializer


Look inside the WriteXml() method above.

--
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
I am having a problem deserializing XML when the root node is missing a namespace declaration. My Type has an XmlTypeAttribut e with a namespace defined. If I attempt to deserialize the XML, I get the dreaded

<elementname xmlns=''> was not expected

exception. If I comment out the XmlTypeAttribut e, it works just fine.

Just
so you know, when I instantiate an instance of an XmlSerializer, I pass a
default namespace to the ctor. Unfortunately that doesn't seem to

work.
So, how can I get the XmlSerializer to accept XML that is missing

namespace
declarations?

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT



Nov 12 '05 #4
Chris,
I am well aware of _why_ the exception occurs. Now I need a way to work
around it. How can I provide a "hint" to the XmlSerializer that if the root
node has either an empty xmlns, or none at all, that the root node namespace
_should_ be something, and it's OK if the node is missing the declaration.

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh Daily™
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
David,

The code you posted works fine for me with this code:

TransferManifes t mfst = new TransferManifes t();
string xml = TransferManifes t.WriteXml( mfst );
mfst = TransferManifes t.ReadXml( xml );

but I removed the three array type properties

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "filelist")]
public FileList[] FileLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "folderlist ")]
public FolderList[] FolderLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "uploadinfo ")]
public UploadInfo[] UploadInfos;

because I didn't have the class definitions.

The root element

<transfermanife st>

you posted would not deserialize because it's missing the XML namespace that you declared with the XmlRoot and XmlType attributes. The root element needs a namespace declaration like this:

<transfermanife st xmlns=http://codenoevil.com/TransferManifes t.xsd>

which your code produces.

You could either post more code, or follow the instructions at [0] on how to debug deserialization .

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Chris,
Look inline below:

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:eN******** *****@TK2MSFTNG P12.phx.gbl...
David,

Can you post:

* The serialization class

[System.Xml.Seri alization.XmlTy peAttribute(Nam espace=Transfer Manifest.DEFAUL
T_NAMESPACE)]

[System.Xml.Seri alization.XmlRo otAttribute(Nam espace=Transfer Manifest.DEFAUL
T_NAMESPACE, IsNullable=fals e, ElementName="tr ansfermanifest" )]
public class TransferManifes t {

public const string DEFAULT_NAMESPA CE =
"http://codenoevil.com/TransferManifes t.xsd";

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "filelist")]
public FileList[] FileLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "folderlist ")]
public FolderList[] FolderLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "uploadinfo ")]
public UploadInfo[] UploadInfos;

#region XML (de)serializati on code
public static TransferManifes t ReadXml(string xml)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest));

xmlSerializer.U nknownNode+= new
XmlNodeEventHan dler(XmlSeriali zer_UnknownNode );
xmlSerializer.U nknownAttribute += new
XmlAttributeEve ntHandler(XmlSe rializer_Unknow nAttribute);

try
{
TransferManifes t transferManifes t =
(TransferManife st)xmlSerialize r.Deserialize(
new StringReader(xm l)
);

return transferManifes t;
}
catch(Exception ex)
{
throw new ApplicationExce ption("Transfer Manifest failed to

deserialize: "
+ ex.Message, ex);
}
}

public static string WriteXml(Transf erManifest transferManifes t)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest), DEFAULT_NAMESPA CE);

StringWriter stringWriter = new StringWriter();

xmlSerializer.S erialize(string Writer, transferManifes t);

return stringWriter.To String();
}

private static void XmlSerializer_U nknownNode
(object sender, XmlNodeEventArg s e)
{
Debug.WriteLine ("Unknown Node:" + e.Name + "\t" + e.Text);
}

private static void XmlSerializer_U nknownAttribute
(object sender, XmlAttributeEve ntArgs e)
{
System.Xml.XmlA ttribute attr = e.Attr;
Debug.WriteLine ("Unknown attribute " +
attr.Name + "='" + attr.Value + "'");
}
#endregion
}

* the tag of the root element, including all namespace definitions
<transfermanife st>
* the line of code where you instantiate the XmlSerializer


Look inside the WriteXml() method above.

--
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> I am having a problem deserializing XML when the root node is missing a > namespace declaration. My Type has an XmlTypeAttribut e with a namespace > defined. If I attempt to deserialize the XML, I get the dreaded
>
> <elementname xmlns=''> was not expected
>
> exception. If I comment out the XmlTypeAttribut e, it works just
fine. Just
> so you know, when I instantiate an instance of an XmlSerializer, I

pass
a
> default namespace to the ctor. Unfortunately that doesn't seem to

work. >
> So, how can I get the XmlSerializer to accept XML that is missing
namespace
> declarations?
>
> --
> --
>
> David B. Bitton
> da***@codenoevi l.com
> www.codenoevil.com
>
> Code Made Fresh DailyT
>
>



Nov 12 '05 #5
David,

Now I am with you ... and tha bad news is that the XmlSerializer is not
really intended to do what you're trying to do. From an XML perspective,
you're trying to deserialize two entirely different XML formats. While the
two formats share the same element names, their QNames (name+namespace ) are
different. An XmlSerializer is really only good at processing one format.

You may be able to work around this with two serializer instances. One that
you instantiate with

XmlSerializer ser1 = new XmlSerializer( typeof( TransferManifes t ) );

and another one that you instantiate with XmlOverrideAttr ibutes supplied to
the constructor:

<notTested>
XmlAttributeOve rrides overrides = new XmlAttributeOve rrides();
XmlAttributes atts = new XmlAttributes() ;
// override the XmlType and XmlRoot attributes
atts.XmlType = new XmlTypeAttribut e();
atts.XmlRoot = new XmlRootAttribut e();
overrides.Add( typeof( TransferManifes t ), atts );
XmlSerializer ser2 = new XmlSerializer( typeof( TransferManifes t ),
overrides );
</notTested>

then you read the first element of your XML document with an XmlTextReader
to determine if any namespaces are declared.

TransferManifes t tm = null;
XmlTextReader reader = new XmlTextReader( new StringReader( xml ) );
if( reader.Read() )
{
if( reader.Namespac eURI = "" )
{
reader.Close();
tm = ser2.Deserializ e( new StringReader( xml ) );
}
else
{
reader.Close();
tm = ser1.Deserializ e( new StringReader( xml ) );
}
}

Let me know if this works ...
--

Christoph Schittko [MVP, XmlInsider]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:el******** ******@tk2msftn gp13.phx.gbl...
Chris,
I am well aware of _why_ the exception occurs. Now I need a way to work around it. How can I provide a "hint" to the XmlSerializer that if the root node has either an empty xmlns, or none at all, that the root node namespace _should_ be something, and it's OK if the node is missing the declaration.

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote in
message news:%2******** ********@tk2msf tngp13.phx.gbl. ..
David,

The code you posted works fine for me with this code:

TransferManifes t mfst = new TransferManifes t();
string xml = TransferManifes t.WriteXml( mfst );
mfst = TransferManifes t.ReadXml( xml );

but I removed the three array type properties

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "filelist")]
public FileList[] FileLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "folderlist ")]
public FolderList[] FolderLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "uploadinfo ")]
public UploadInfo[] UploadInfos;

because I didn't have the class definitions.

The root element

<transfermanife st>

you posted would not deserialize because it's missing the XML namespace that
you declared with the XmlRoot and XmlType attributes. The root element

needs
a namespace declaration like this:

<transfermanife st xmlns=http://codenoevil.com/TransferManifes t.xsd>

which your code produces.

You could either post more code, or follow the instructions at [0] on how to
debug deserialization .

--
HTH
Christoph Schittko [MVP]
Software Architect, .NET Mentor

"David B. Bitton" <da***@codenoev il.com> wrote in message
news:%2******** ********@TK2MSF TNGP11.phx.gbl. ..
Chris,
Look inline below:

--
--

David B. Bitton
da***@codenoevi l.com
www.codenoevil.com

Code Made Fresh DailyT
"Christoph Schittko [MVP]" <ch************ ********@austin .rr.com> wrote
in message news:eN******** *****@TK2MSFTNG P12.phx.gbl...
> David,
>
> Can you post:
>
> * The serialization class

[System.Xml.Seri alization.XmlTy peAttribute(Nam espace=Transfer Manifest.DEFAUL T_NAMESPACE)]

[System.Xml.Seri alization.XmlRo otAttribute(Nam espace=Transfer Manifest.DEFAUL
T_NAMESPACE, IsNullable=fals e, ElementName="tr ansfermanifest" )]
public class TransferManifes t {

public const string DEFAULT_NAMESPA CE =
"http://codenoevil.com/TransferManifes t.xsd";

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "filelist")]
public FileList[] FileLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "folderlist ")]
public FolderList[] FolderLists;

/// <remarks/>
[System.Xml.Seri alization.XmlEl ementAttribute( "uploadinfo ")]
public UploadInfo[] UploadInfos;

#region XML (de)serializati on code
public static TransferManifes t ReadXml(string xml)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest));

xmlSerializer.U nknownNode+= new
XmlNodeEventHan dler(XmlSeriali zer_UnknownNode );
xmlSerializer.U nknownAttribute += new
XmlAttributeEve ntHandler(XmlSe rializer_Unknow nAttribute);

try
{
TransferManifes t transferManifes t =
(TransferManife st)xmlSerialize r.Deserialize(
new StringReader(xm l)
);

return transferManifes t;
}
catch(Exception ex)
{
throw new ApplicationExce ption("Transfer Manifest failed to deserialize:
"
+ ex.Message, ex);
}
}

public static string WriteXml(Transf erManifest transferManifes t)
{
XmlSerializer xmlSerializer =
new XmlSerializer(t ypeof(TransferM anifest), DEFAULT_NAMESPA CE);

StringWriter stringWriter = new StringWriter();

xmlSerializer.S erialize(string Writer, transferManifes t);

return stringWriter.To String();
}

private static void XmlSerializer_U nknownNode
(object sender, XmlNodeEventArg s e)
{
Debug.WriteLine ("Unknown Node:" + e.Name + "\t" + e.Text);
}

private static void XmlSerializer_U nknownAttribute
(object sender, XmlAttributeEve ntArgs e)
{
System.Xml.XmlA ttribute attr = e.Attr;
Debug.WriteLine ("Unknown attribute " +
attr.Name + "='" + attr.Value + "'");
}
#endregion
}
> * the tag of the root element, including all namespace definitions

<transfermanife st>

> * the line of code where you instantiate the XmlSerializer

Look inside the WriteXml() method above.

>
> --
> Christoph Schittko [MVP]
> Software Architect, .NET Mentor
>
> "David B. Bitton" <da***@codenoev il.com> wrote in message
> news:%2******** ********@tk2msf tngp13.phx.gbl. ..
> > I am having a problem deserializing XML when the root node is

missing
a
> > namespace declaration. My Type has an XmlTypeAttribut e with a

namespace
> > defined. If I attempt to deserialize the XML, I get the dreaded
> >
> > <elementname xmlns=''> was not expected
> >
> > exception. If I comment out the XmlTypeAttribut e, it works just

fine. > Just
> > so you know, when I instantiate an instance of an XmlSerializer, I

pass
a
> > default namespace to the ctor. Unfortunately that doesn't seem to

work.
> >
> > So, how can I get the XmlSerializer to accept XML that is missing
> namespace
> > declarations?
> >
> > --
> > --
> >
> > David B. Bitton
> > da***@codenoevi l.com
> > www.codenoevil.com
> >
> > Code Made Fresh DailyT
> >
> >
>
>



Nov 12 '05 #6
Hi David,

I agree with Chris on this. Since you're serializing two Xml documents with
different formats, I think you have to create two serializers to get them
work. For workaround, Chris has provided us with a good example. If
anything is unclear, please feel free to reply to the post. I'll try my
best to help.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Nov 12 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
4238
by: insane79 | last post by:
Hi, i have one problem with an xsl trasformation (I'm using Xalan) The source XML document is the following: <?xml version = '1.0' encoding = 'ISO-8859-1'?> <ROOT xmlns:NAME='old_namespace'> <NAME:element>...</NAME:element> <NAME:element>...</NAME:element>
6
8885
by: JoostV | last post by:
How can I set the default namespace of an XmlDocument/XmlElement? I've tried doing something like rootElement.SetAttribute( "xmlns", "http://www.w3.org/2000/xmlns/", "http://www.some.org/theschema" ); on the DocumentElement. However, this fails. Any ideas??
6
3519
by: Nikhil Patel | last post by:
Hi all, Following is a portion of an XML document. I need to remove all nodes that belong to ns0 without deleting their child nodes. So in the following example , I want to delete "ns0:Proposal" and "ns0:Company" but I do not want to delete their child nodes("w:p","w:r","w:t"). How can I do this? <ns0:Proposal> <ns0:Company> <w:p> <w:r>
1
3903
by: Dorte | last post by:
Hi, From an ASP.NET application I am loading an xml-file in order to modify it. This is part of the code I have produced so far: XmlDocument XMLDoc = new XmlDocument(); XmlNamespaceManager nsmanager = new XmlNamespaceManager(XMLDoc.NameTable); nsmanager.AddNamespace("rd",
2
11830
by: Joe Bloggs | last post by:
Hi, I am trying to remove the namespace in the root node in the following XML, <ordersHistory xmlns="http://tempuri.org/Orders.xsd"> <order number="PO-1" added="12/12/2002"> <client name="Microsoft"> <address country="USA" city="Washington" /> <notes> Produces a great framework for developing applications.
4
2274
by: Karine Bosch | last post by:
Hi, My xml document uses different namespaces: <x:root xmlns:x="x:ns:meta/"> <element1 xmlns:adam="http://ns.alfaprint.be/"> </root> This gives problems when using an XPath query. I already created 2 namespace managers
8
2030
by: Simon Brooke | last post by:
I was debugging a new XML generator tonight and trying to determine why it wasn't working; and realised my dom printer does not output XML namespace declarations. My method to output an Element is as follows: /** * Print an element node, and, by recursive descent, it's children * * @param node the node to print
11
9861
by: Michael Bray | last post by:
I'm playing around with XElement stuff, and I've come across a difficulty. The XML document that I'm reading contains an xmlns declaration on the main node... <root xmlns="http://www.me.com"> <ANode> <BNode>Hello</BNode> <BNode>Goodbye</BNode> </ANode> </root>
1
1852
by: farseerfc | last post by:
Hi, everyone here loves C++; As a student studying data structure, I'm writting a single list (with only one pointer to identity the next node in its node struct) simulating std::list like: template <typename T, typename Allocclass slist {...}; Here Alloc accepts a std::allcator . And within the same namespace I wrote its iterator:
0
8889
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9116
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8099
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6702
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6011
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4784
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3228
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2637
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2157
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.