xmlns=''> was not expected.

This is a multi-part message in MIME format.

------=_NextPart_000_000B_01C48D23.5FBF4980
Content-Type: text/plain;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

Hi guys,Does any1 know what this error is all about, what I am trying to =
do is deserialize a XML, below is my code, let me know what I am doing =
wrongpublic class test{xin =3D "<?xml version=3D'1.0' =
encoding=3D'UTF-8'?><InSession><PassWord>foo</PassWord><UserName>foo@foo.=
com</UserName></InSession>";XmlSerializer serializer =3D new =
XmlSerializer(typeof(cXmlBS));XmlTextReader tr =3D new XmlTextReader(new =
System.IO.StringReader(xin));cXmlBS cx =3D =
(cXmlBS)serializer.Deserialize(tr);tr.Close();}public class =
cXmlBS{public String PassWord;public String =
UserName;}System.InvalidOperationException: There is an error in XML =
document (1, 40). ---> System.InvalidOperationException: <InSession =
xmlns=3D''> was not expected.
   at =
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Rea=
d4_cXmlBS()
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader =
xmlReader, String encodingStyle)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader =
xmlReader)
   at BathamWS.LoginService.BeginSession(String xin) in =
c:\inetpub\wwwroot\bathamws\loginws.asmx.cs:line 62
help is appreciated, thanksshailendra batham
------=_NextPart_000_000B_01C48D23.5FBF4980
Content-Type: text/html;
	charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2800.1106" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY>
<DIV><PRE><FONT face=3DArial size=3D2>Hi guys,</FONT></PRE><PRE><FONT =
face=3DArial size=3D2>Does any1 know what this error is all about, what =
I am trying to do is deserialize a XML, below is my code, let me know =
what I am doing wrong</FONT></PRE><PRE><FONT size=3D2><P>public class =
test</P><P>{</P><P>xin =3D "&lt;?xml version=3D'1.0' =
encoding=3D'UTF-8'?&gt;&lt;InSession&gt;&lt;PassWord&gt;foo&lt;/PassWord&=
gt;&lt;UserName&gt;foo@foo.com&lt;/UserName&gt;&lt;/InSession&gt;";</P><P=
>XmlSerializer serializer =3D </FONT><FONT color=3D#0000ff =
size=3D2>new</FONT><FONT size=3D2> XmlSerializer(</FONT><FONT =
color=3D#0000ff size=3D2>typeof</FONT><FONT =
size=3D2>(cXmlBS));</P><P></FONT><FONT size=3D2></FONT><P><FONT =
face=3DArial size=3D2></FONT><FONT color=3D#008000 =
size=3D2></P></FONT><FONT size=3D2>XmlTextReader tr =3D </FONT><FONT =
color=3D#0000ff size=3D2>new</FONT><FONT size=3D2> =
XmlTextReader(</FONT><FONT color=3D#0000ff size=3D2>new</FONT><FONT =
size=3D2> System.IO.StringReader(xin));</P><P>cXmlBS cx =3D =
(cXmlBS)serializer.Deserialize(tr);</P><P>tr.Close();</P><P><FONT =
face=3DArial>}</FONT></P><P><FONT face=3DArial></FONT>&nbsp;</P><FONT =
size=3D2><P></FONT><FONT color=3D#0000ff size=3D2>public</FONT><FONT =
size=3D2> </FONT><FONT color=3D#0000ff size=3D2>class</FONT><FONT =
size=3D2> cXmlBS</P><P>{</P><P></FONT><FONT color=3D#0000ff =
size=3D2>public</FONT><FONT size=3D2> String =
PassWord;</P><P></FONT><FONT color=3D#0000ff size=3D2>public</FONT><FONT =
size=3D2> String UserName;</P><P>}</P></FONT></FONT></PRE><PRE><FONT =
face=3DArial size=3D2>System.InvalidOperationException: There is an =
error in XML document (1, 40). ---&gt; System.InvalidOperationException: =
&lt;InSession xmlns=3D''&gt; was not expected.
   at =
Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Rea=
d4_cXmlBS()
   --- End of inner exception stack trace ---
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader =
xmlReader, String encodingStyle)
   at System.Xml.Serialization.XmlSerializer.Deserialize(XmlReader =
xmlReader)
   at BathamWS.LoginService.BeginSession(String xin) in =
c:\inetpub\wwwroot\bathamws\loginws.asmx.cs:line 62
</FONT></PRE><PRE><FONT face=3DArial size=3D2>help is appreciated, =
thanks<BR>shailendra batham</FONT></PRE></DIV></BODY></HTML>

------=_NextPart_000_000B_01C48D23.5FBF4980--

0
sgbatham (3)
8/29/2004 12:20:54 AM
dotnet.xml 7266 articles. 0 followers. Follow

4 Replies
3296 Views

Similar Articles

[PageSpeed] 20

"Shailendra Batham" <sgbatham@sbcglobal.net> wrote in message news:Fj9Yc.9143$QJ3.8029@newssvr21.news.prodigy.com...
> Does any1 know what this error is all about, what I am trying to do is deserialize
> a XML, below is my code, let me know what I am doing wrong
: :
> System.InvalidOperationException: There is an error in XML document (1, 40).
> ---> System.InvalidOperationException: <InSession xmlns=''> was not expected.
>    at Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read4_cXmlBS()

The XML you are trying to deserialize looks like this,

<InSession>
    <PassWord>foo</PassWord>
    <UserName>foo@foo.com</UserName>
</InSession>

However, the class you are deserializing into looks like this,

public class cXmlBS
{
    public String PassWord;
    public String UserName;
}

The difference is the root element name.  Your XML contains an element named
"InSession" (without xmlns, that's all the message is saying there, it's extraneous
to the problem at hand).  However, Deserialize( ) only knows how to look for
an element named "cXmlBS".  It did not expect to see an element named "In-
Session," that is all the InvalidOperationException is telling you.

There are two solutions, change the element name in the XML you're deserializing
to match the class/type name:

<cXmlBS>
    <PassWord>foo</PassWord>
    <UserName>foo@foo.com</UserName>
</cXmlBS>

or you can decorate the class/type name with an XmlRootAttribute that tells the
XmlSerializer that you want the XML element "InSession" to correspond to the
class cXmlBS's root element.

[XmlRoot( "InSession")]
public class cXmlBS
{
    public String PassWord;
    public String UserName;
}


Derek Harmon


0
loresayer (275)
8/29/2004 3:41:05 AM
Thanks Derek for the help I got my problem solved,

I have another question.

<?xml version='1.0' encoding='UTF-8'?>
  <State>
    <California>
        <City>
           <LosAngeles></LosAngeles>
           <SantaMonica></SantaMonica>
        <City>
    </California>
    <Illinois>
        <City>
           <Chicago></Chicago>
        <City>
    </Illinois>
  </State>

suppose this is my xml document, how can I achieve serialization and 
deserialization on this xml and get the results.

"Derek Harmon" <loresayer@msn.com> wrote in message 
news:%239ylFoXjEHA.3348@TK2MSFTNGP12.phx.gbl...
> "Shailendra Batham" <sgbatham@sbcglobal.net> wrote in message 
> news:Fj9Yc.9143$QJ3.8029@newssvr21.news.prodigy.com...
>> Does any1 know what this error is all about, what I am trying to do is 
>> deserialize
>> a XML, below is my code, let me know what I am doing wrong
> : :
>> System.InvalidOperationException: There is an error in XML document (1, 
>> 40).
>> ---> System.InvalidOperationException: <InSession xmlns=''> was not 
>> expected.
>>    at 
>> Microsoft.Xml.Serialization.GeneratedAssembly.XmlSerializationReader1.Read4_cXmlBS()
>
> The XML you are trying to deserialize looks like this,
>
> <InSession>
>    <PassWord>foo</PassWord>
>    <UserName>foo@foo.com</UserName>
> </InSession>
>
> However, the class you are deserializing into looks like this,
>
> public class cXmlBS
> {
>    public String PassWord;
>    public String UserName;
> }
>
> The difference is the root element name.  Your XML contains an element 
> named
> "InSession" (without xmlns, that's all the message is saying there, it's 
> extraneous
> to the problem at hand).  However, Deserialize( ) only knows how to look 
> for
> an element named "cXmlBS".  It did not expect to see an element named "In-
> Session," that is all the InvalidOperationException is telling you.
>
> There are two solutions, change the element name in the XML you're 
> deserializing
> to match the class/type name:
>
> <cXmlBS>
>    <PassWord>foo</PassWord>
>    <UserName>foo@foo.com</UserName>
> </cXmlBS>
>
> or you can decorate the class/type name with an XmlRootAttribute that 
> tells the
> XmlSerializer that you want the XML element "InSession" to correspond to 
> the
> class cXmlBS's root element.
>
> [XmlRoot( "InSession")]
> public class cXmlBS
> {
>    public String PassWord;
>    public String UserName;
> }
>
>
> Derek Harmon
>
> 


0
sgbatham (3)
8/29/2004 6:05:14 PM
This is a multi-part message in MIME format.

------=_NextPart_000_0016_01C48F0C.89834EC0
Content-Type: text/plain;
	charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

Apply XmlRoot attribute to your class:
=20
[XmlRoot("InSession")]public class cXmlBS{public String PassWord;public =
String UserName;}


------=_NextPart_000_0016_01C48F0C.89834EC0
Content-Type: text/html;
	charset="ISO-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=3DContent-Type content=3D"text/html; =
charset=3Diso-8859-1">
<META content=3D"MSHTML 6.00.2600.0" name=3DGENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=3D#ffffff>
<DIV><FONT size=3D2><FONT face=3DArial>Apply XmlRoot attribute to your=20
class:</FONT></FONT></DIV>
<DIV><FONT size=3D2>&nbsp;</DIV><PRE dir=3Dltr><FONT =
size=3D2><P>[XmlRoot("InSession")]</FONT><FONT =
size=3D2></FONT></P><P><FONT color=3D#0000ff size=3D2>public</FONT><FONT =
size=3D2> </FONT><FONT color=3D#0000ff size=3D2>class</FONT><FONT =
size=3D2> cXmlBS</P><P>{</P><P></FONT><FONT color=3D#0000ff =
size=3D2>public</FONT><FONT size=3D2> String =
PassWord;</P><P></FONT><FONT color=3D#0000ff size=3D2>public</FONT><FONT =
size=3D2> String UserName;</P><P>}</FONT></FONT></P></PRE></BODY></HTML>

------=_NextPart_000_0016_01C48F0C.89834EC0--

0
idiot1 (1)
8/31/2004 12:42:28 AM
"Shailendra Batham" <sgbatham@sbcglobal.net> wrote in message news:uVoYc.13561$2%2.60@newssvr29.news.prodigy.com...
> <?xml version='1.0' encoding='UTF-8'?>
>   <State>
>     <California>
>         <City>
>            <LosAngeles></LosAngeles>
>            <SantaMonica></SantaMonica>
>         <City>
>     </California>
>     <Illinois>
>         <City>
>            <Chicago></Chicago>
>         <City>
>     </Illinois>
>   </State>
>
> suppose this is my xml document, how can I achieve serialization and
> deserialization on this xml and get the results.

It's not possible to serialize/deserialize this based on serialization
attributes alone because you've encoded the "data" into the element
names, instead of using the elements to describe it's "structure."  (I'm
not going to preach why this is generally a bad idea.)

Instead, it's necessary to implement the IXmlSerializable interface.
Here's what you'll need for this little project:

*  One XML schema document (which in this case, cannot
   be too well structured, but you need on nevertheless),

*  Two methods, one deserializing from an XmlReader and the
   other serializing into an XmlWriter.

Making this more concrete involves crafting up the essential object
model you've presupposed in your desired XML document, so let
me do that first.  These classes will be light on luxury (the IEnumerable
implementation isn't necessary for serialization, but to simplify the
test driver) while stressing relevance.

- - - States.cs
using System;
using System.Collections;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;

public class CityObj
{
    string cityName;

    public CityObj( string cityName)
    {
        this.cityName = cityName;
    }

    public string City
    {
        get
        {
            return this.cityName;
        }
        set
        {
            this.cityName = value;
        }
    }
}

public class StateObj : IEnumerable
{
    string    stateName;
    ArrayList cityList;

    public StateObj( string stateName)
    {
        this.stateName = stateName;
        this.cityList = new ArrayList( );
    }

    public StateObj( string stateName, CityObj[ ] cities)
    {
        this.stateName = stateName;
        this.cityList = new ArrayList( cities);
    }

    public CityObj Add( string cityName)
    {
        CityObj city = new CityObj( cityName);
        this.cityList.Add( city);
        return city;
    }

    public string StateName
    {
        get
        {
            return this.stateName;
        }
        set
        {
            this.stateName = value;
        }
    }

    IEnumerator IEnumerable.GetEnumerator( )
    {
        return ((IEnumerable)( this.cityList)).GetEnumerator( );
    }
}


public class StateCollection : IXmlSerializable, IEnumerable
{
    ArrayList stateList;
    bool deserializedOK;

    public StateCollection( )
    {
        this.stateList = new ArrayList( );
        this.deserializedOK = true;
    }

    public bool IsOK
    {
        get
        {
            return this.deserializedOK;
        }
    }

    public int Count
    {
        get
        {
            return this.stateList.Count;
        }
    }

    public StateObj Add( string stateName)
    {
        StateObj st = new StateObj( stateName);
        this.stateList.Add( st);
        return st;
    }

    public StateObj Add( StateObj state)
    {
        this.stateList.Add( state);
        return state;
    }

    IEnumerator IEnumerable.GetEnumerator( )
    {
        return ((IEnumerable)( this.stateList)).GetEnumerator( );
    }

    public XmlSchema GetSchema( )
    {
        // TO BE SUPPLIED.
    }

    public void ReadXml( XmlReader reader)
    {
        // TO BE SUPPLIED.
    }

    public void WriteXml( XmlWriter writer)
    {
        // TO BE SUPPLIED.
    }
}
- - -

The first method of IXmlSerializable that you're going to implement
is GetSchema( ).  This method needs to return an XML Schema
Document describing the expected format of the serialized instance
XML.  Since I can't anticipate all of the states / provinces that your
application might require, there's very little I can do as far as defining
<xs:element>'s of it's structure.  Instead, the heart of the lax schema
I'm going to use is the <xs:any> (note that the processContent attribute
is not allowed, however the any element will permit you free-wheeling
lattitude in the content of that element).

Here's the schema document, complete for your perusal.

- - - state.xsd
<?xml version='1.0'?>
<xs:schema id="States" xmlns:xs='http://www.w3.org/2001/XMLSchema'>

<!-- Global Type Definitions -->
<xs:complexType name="StatesType">
    <xs:sequence>
        <!-- Allow literally any content in the empty xmlns='' -->
        <xs:any namespace="##local" minOccurs="1" maxOccurs="unbounded" />
    </xs:sequence>
</xs:complexType>

<!-- Global Element Declaration -->
<xs:element name="States" type="StatesType" />

</xs:schema>
- - -

Now let's fill out the GetSchema( ) method, which simply loads
this file and returns a SOM XmlSchema instance.

    public XmlSchema GetSchema()
    {
        FileStream xsdFile = new FileStream( "State.xsd", FileMode.Open);

        // Optional ValidationEventHandler can be passed as 2nd argument here.
        XmlSchema xsd = XmlSchema.Read( xsdFile, null);

        xsdFile.Close( );
        return xsd;
    }

Pretty self-explanatory.  Normally if we had had a more stringent
schema document, the step in which XmlSerializer gets the schema
would also perform schema-validation and it could detect validation
errors here (or notify your program through a ValidationEventHandler
you register in the XmlSchema.Read( ) method above).

The example I'm demonstrating will put the serialized content into a
container element named after the class, StateCollection, but
within there the content closely corresponds to what you want.
You may re-align the object model as is necessary for the app
at hand, but make sure you retain the xsd and xsi namespace
declarations.

Writing the XML out is the simplest operation, taking advantage
of the IEnumerable support in the object model we're using.  It's
a straightforward application of the XmlWriter class that the
XmlSerializer will pass to this method when time comes to serialize
the StateCollection instance (or other IXmlSerializable implementation).

    public void WriteXml( XmlWriter writer)
    {
        writer.WriteStartElement( "State");
        writer.WriteAttributeString( "xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
        writer.WriteAttributeString( "xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");

        foreach( StateObj st in this )
        {
            writer.WriteStartElement( st.StateName);

            // Assuming <City> is required, even when there are no child elements;
            // if <City> is optional based on the existence of child elements, then
            // move WriteStartElement( "City") and WriteEndElement() inside foreach
            // loop and use a firstTimeOnly flag to write them.
            //
            writer.WriteStartElement( "City");
            foreach( CityObj city in st)
            {
                writer.WriteStartElement( city.City);
                writer.WriteFullEndElement( );
            }
            writer.WriteFullEndElement( ); // </City>

            writer.WriteFullEndElement(); // </StateName>
        }

        writer.WriteEndElement();  // </State>
    }

The reading portion is probably the most complicated as it involves
we maintain a state machine.  In this example, when I'm between
the <State> element and the <City> element, I know any elements
I encounter are state names.  If I've already encountered a <City>
element, but not yet a </City> closing tag, then I know any elements
are city names contained by the last (in-scope) state name.

The key indications that I'm changing state in my reading routine
are based off of the reader's IsStartElement( ) method, and tests
of whether I've encountered a NodeType of XmlEndElement.  At
these points I look at the node's LocalName (which is either "State",
a state name, "City", or a city name).  Although the end element
won't yield a local name, by diligently pushing every name onto a
Stack when they were start elements, I can safely pop them off
when I need the name of the current end element.

In order to track the transitions of this state machine I use a 'depth'
indicator where the opening/closing <State> is at the most shallow
depth (betweenStateAndCity == 1) and city names after a <City>
are the greatest depth (betweenStateAndCity == 3).

    public void ReadXml( XmlReader reader)
    {
        Stack hopper = new Stack( );
        bool reachedEnd = false;
        int betweenStateAndCity = 1;

        try
        {
            StateObj currentState = null;
            while ( reader.Read( ) && !reachedEnd )
            {
                if ( reader.IsStartElement( ) )
                {
                    string name = reader.LocalName;
                    hopper.Push( name);

                    if ( 0 == name.CompareTo( "State"))
                    {
                        ++betweenStateAndCity;
                    }
                    else if ( 0 == name.CompareTo( "City"))
                    {
                        ++betweenStateAndCity;
                    }
                    else if ( ( 2 == betweenStateAndCity ) && ( null == currentState ) )
                    {
                        currentState = new StateObj( name);
                    }
                    else if ( ( 3 == betweenStateAndCity ) && ( null != currentState ) )
                    {
                        currentState.Add( name);
                    }
                    Debug.WriteLine( "pushed {0}", name);
                }
                else if ( reader.NodeType == XmlNodeType.EndElement )
                {
                    if ( hopper.Count > 0 )
                    {
                        string name = hopper.Pop( ) as string;
                        if ( 0 == name.CompareTo( "City"))
                        {
                            this.Add( currentState);
                            currentState = null;
                            --betweenStateAndCity;
                        }
                        if ( 0 == name.CompareTo( "State"))
                        {
                            reachedEnd = true;
                            --betweenStateAndCity;
                        }
                        Debug.WriteLine( "popped {0}", (name == null)? "(null)": name);
                    }
                }
            }
        }
        catch ( XmlException xe)
        {
            Debug.WriteLine( xe.Message);
            this.deserializedOK = false;
        }
    }

While the subtleties of the above code's state transitions settle,
let's create a test driver that tries out this solution.  I mean, will
IXmlSerializable really work, after all this typing you've done,
and having decomposed the schema of your desired XML into
an XmlReader implementation?  Maybe this was wasted effort,
you might be thinking, at least until you can execute a tangible
example.

Here is that example.

- - - StateApp.cs
public class App
{
    public static void Main( )
    {
        // Create a StateCollection
        //
        StateCollection usa = new StateCollection( );

        // Add the sunshine state..
        //
        StateObj ca = usa.Add( "California");
        ca.Add( "LosAngeles");
        ca.Add( "SantaMonica");

        // Add the land of Lincoln and the Windy City..
        //
        StateObj il = usa.Add( "Illinois");
        il.Add( "Chicago");

        // Give me something to write to (this will be UTF-16, but you can
        // always serialize to another intermediary using UTF-8 encoding
        // as your example XML presupposes).
        //
        StringBuilder buf = new StringBuilder( 1024);
        StringWriter sw = new StringWriter( buf);

        // Serialize the above StateCollection to XML in a string.
        //
        XmlSerializer ser = new XmlSerializer( typeof( StateCollection));
        ser.Serialize( sw, usa);
        sw.Flush( );

        // Display results.
        //
        string xml = buf.ToString( );
        Console.WriteLine( xml);

        // Turn the string around into a Reader and then Deserialize it
        // into a new instance of the StateCollection type.
        //
        StringReader sr = new StringReader( xml);
        StateCollection eeuu = ser.Deserialize( sr) as StateCollection;
        if ( null != eeuu )
        {
            // Did it deserialize successfully?  (this was a property I impl'd above.)
            //
            Console.WriteLine( eeuu.IsOK);

            // Loop through each State in this deserialized StateCollection.
            //
            foreach( StateObj st in eeuu)
            {
                Console.WriteLine( st.StateName);

                // Loop through each City in this deserialized State.
                //
                foreach( CityObj city in st)
                {
                    Console.WriteLine( "\t" + city.City);
                }
            }
        }
    }
}
- - -

When you run this you'll observe the following XML is generated by
the WriteXml( ) method,

- - - state.xml
<?xml version="1.0" encoding="utf-16"?>
<StateCollection>
  <State xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.o
rg/2001/XMLSchema-instance">
    <California>
      <City>
        <LosAngeles>
        </LosAngeles>
        <SantaMonica>
        </SantaMonica>
      </City>
    </California>
    <Illinois>
      <City>
        <Chicago>
        </Chicago>
      </City>
    </Illinois>
  </State>
</StateCollection>
- - -

The object model that's deserialized from this has the following structure,
matching what the test driver application originally created:

California
        LosAngeles
        SantaMonica
Illinois
        Chicago


So, after all that, it is possible.  Nevertheless, designing a schema in
which the local names of elements contain the information content of
the document, instead of describing it's structure, should be avoided.
Think of how much easier the following would've been to serialize (or
represent in an XML schema document):

- - - BetterStates.xml
<States>
    <State name="California">
        <City name="Los Angeles" />
        <City name="Santa Monica" />
    </State>
    <State name="Illinois">
        <City name="Chicago" />
    </State>
</States>
- - -

In this schema, the elements and attribute names describe the structure,
and their values are the information content.  Much more flexible and
adaptable, than the original solution (and it serializes more easily, too!).  :-)


Derek Harmon


0
loresayer (275)
8/31/2004 3:57:42 AM
Reply:

Similar Artilces:

Date() not functioning as expected
Hi, I'm working with Access 2003 at work, and we have reports that show projects with all associated milestones, and employees are supposed to enter the date of completion when the milestone is met. One of our reports is called 'Missing Dates', and it returns a list of all projects with associated milestones ONLY if there is a proposed milestone date between 1/1/2001 and the current date. The funtion is currently set up as Between #1/1/2001# And [Enter Date mm/dd/yy]. This works perfectly. I'm trying to get it where the user doesn't even have to enter the cu...

Excel not filtering as expected
Don't know if anyone's come across this before, but I would be glad of some reassurance that it's not just me, and if anyone knows a way round it, that would be even better! Basically, we are using a spreadsheet to keep track of (amongst other things) the history of our processes. One of the columns therefore may have many entries within any one cell, reflecting the different dates on which actions were taken. I know it's not ideal but I've inherited it and I'm stuck with it for the time being. To make it easier to distinguish between the date entries, I have used the ...

Removing xmlns:xsd and xmlns:xsi when using ImportNode
I'm doing some document merging where I want to bring in an XmlDocument and import its document element into another document deeper in its tree. However, when serializing my underlying objects, .Net likes to add these namespaces: <RootNode xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <ChildNode xmlns="MyObjectHierarchyNamespace/> </RootNode> The problem this is causing me is that any node(s) that have those namespaces get properly imported into the XML, but those nodes fail to dese...

List<T> not performing as expected
I have an form that displays a slideshow of pictures. It uses a List<PictureFile> to store the slideshow photos, filenames, and options whether or not a photo should be included in a list to export later. When I make one or more items of List<PictureFile> included, the GoToNextPicture and GoToPreviousPicture methods do not work correctly and whenever they attempt to move to an included picture, they jump around. I suspected something in List<T>.ElementAt and switched to List<T>[index] but had no luck. My code: (I trimmed out some irrelevant methods and a...

GetFileTime() not returning expected results.
I am writing a file synchronization app and have a problem checking for out of sync files based on last modified date and time. If I copy files from c: to a USB drive e:, the last modifed time may change by a second. I see this when I call GetFileTime() on both files and look at the last write time. I can also see this by looking at the file properties. This occurs even if the last modified time is months old. Why would this be happening and how can I get around it to check for files with the same last write date and time? sgomon wrote: > I am writing a file synchronization app ...

Report does not contain all the records I expect
I have three tables (Contacts, Children, Other Adults). They are all related by the ContactID. Not all contacts have children, some have more than one adult in the family, not all have other adults. I wanted a report that included all adults and all children for each contact. I created a query of Contacts and their children and tried to insert a subreport of the other adults. It worked but only contained half of the contacts in my original table. Can you tell me what the problem might be? You need to LEFT JOIN Contacts to Children and Other Adults tables. If you need more...

Wrong usage of xmlns?
Hi I need to integrate to a system that has XML like this: <Calls xmlns="\\SomeMachine\Share\Schemas\Calls1_2.dtd" Version="1.2"> <Call> <CallRef>Call1</CallRef> <UserRef>286</UserRef> <Details> <Condition>EDITTABLE</Condition> <CallType>Water Damage</CallType> <Select0>Water Damage</Select0> <Select1>386 Kentmore Road</Select1> <Select2>DE56 1UU</Select2> <Select3>Fairly Urgent</Select3> </Details> <Defaults> </Defaults> <Panels> </P...

Howto: Ommit empty xmlns specs?
Hi, I generate Xml with the XmlDocument methods. Now I have the problem, that a node has a namespace declaration but the child text nodes shall not have a namespace specification. The XML should look as follows: <root xmlns="anyURI"> <child 1>My Text</child 1> ... But when generation the XLM, the nodes look like that: <root xmlns="anyURI"> <child 1 xmlns="">My Text</child 1> How can I suppress the xmlns="" in child 1 ??? Thanks for any help! Regards, hd ..PS: C#, VS2005 Generation like this...

Cache not working as expected when using list(of integer)
Hi, Please can someone explain what is happeing here. I'm caching a list of integers but they appear to dissapear when the original values are changed even though there is no dependencies set up. Example code below. Why does the cache dissapear? <%@ Page Language="VB" %> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <script runat="server"> Dim my_int As Integer Dim mylist As New List(Of Integer) Dim myotherlist As New List(O...

XPath problem with two xmlns
I have got file raport.rld which is an XML file generated by MS Reporting Services. The problem is: in this file are tags from two different namespaces xmlns="http://schemas.microsoft.com/sqlserver/reporting/2003/10/reportdefini tion" xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" when I'm trying to use XPATH to get <teble> tag it doesn't work. (the result is empty) I've removed All tegs like <rd:TypeName>System.Int32</rd:TypeName> Now all is working fine but what to do when I have tags from two different...

Too Few Parameters, 1 expected
I'm getting the error too few paremeters, 1 expected with the code below. I'm getting the error at " Set rst3 = dbs.OpenRecordset(strSQL3)". Any help would be much appreciated On Error GoTo Err_cmdCreateRecords_Click Dim intResp As Integer Dim intCount As Integer If ReportDate = "" Or IsNull(ReportDate) Then MsgBox "Please enter a valid report date." ReportDate.SetFocus GoTo Exit_cmdCreateRecords_Click End If intResp = MsgBox("This function will add records for the reporting date specified. Do you wish to continue?", vbO...

newb Declaration Expected error
vb.net 2008 express new project(copy of old one i'm converting to other use) I created a class MCSUtil.vb to hold general utility functions that could be of use in multiple projects 'wanted to move some inline functions that occurred in previous class into a utility class that could provide code reuse. I put these lines in another class who wanted to use the utility class Private m_Util As MCSUtil 'm_Util = new mcsutil 'm_Util.init(true) if i uncomment either or both of the above two lines i get Declaration expected what does that mean? I thought...

WriteXML and xmlns attribute
Hi, I have a dataset in my application that I write to an XML file using WriteXML. The resulting XML file has a xmlns namespace attribute as part of the root element. When I try and create an XSL file to display some data in a browser, I do not get any output unless I strip out the attribute. (I am very new to this stuff). I suppose I could tackle this in two ways: 1. try to make the WriteXML method to omit the namespace attribute 2. create the XSL so that it can cope with it. I think 2. is not for this newsgroup, so my question is: is it possible to have WriteXML omit the...

SqlXmlException
Ok, brand new to SQLXML 3.0 and its various issues. Heres what I'm trying to do: 1. I am trying to load xml data into an empty SQL table from my .NET console application. 2. This isn't a huge amount of data so I'm not interested in BulkXMLLoad (or whatever its called). 3. I have the xml and xml schema ready to go, with (I hope) the proper sql annotations. Heres my xml schema (built via xsd tool with added sql annotations): <?xml version="1.0" encoding="utf-8"?> <xs:schema elementFormDefault="qualified" xmlns:xs="http://www.w3.org/2001/...

X Estimation given an expected Y
Given a table such as this: Month Data 1 3600 2 7200 3 10800 4 12000 5 13450 6 14100 7 13000 8 12340 9 11300 10 10390 how do I get Excel (XP/2002) to predict when, i.e. what month (if ever) the data might touch 0? Charting the graph and adding a trend line (with 5 forward points) nicely illustrates the concept, but how do I get a calculated value? Ps: I have displayed the equation of the trend line and used Goal Seek to find the month values (0.3 and 12.89 where the 2 roots) but I don't want to copy and paste the formula from the chart and run goal seek everytime a new data point is ...

roundtripping and xmlns attributes
I am endeavouring to use .NET v2.0 XML facilities to "roundtrip" reading and writing XML documents - i.e. to end up with _exactly_ what I started with, but I can't seem to figure out how to get an XMLReader to report "xmlns" attributes. It seems to report an "xmlns='MyDefaultURI'" with incorrect data, and doesn't appear to report "xmlns:myprefix="MyPrefixURI" prefix declarations at all. Yes, I know that it correctly processes and resolves namespaces and prefixes etc, but I want to be able to accurately report the...

Redundant xmlns attribute
If I have an XmlDocument with a deep hierarchy of nodes, with a documentElement having an attribute xmlns="http://someurl.com" and all children inheriting that namespace (but not having the xmlns attribute explicitly declared), then why is it that when I perform appendChild(someNode) on an existing node deep in the hierarchy, where someNode has been created by an XmlSerializer with the namespace set to be the aforementioned "http://someurl.com", the appended node has the xmlns attribute explicitly declared in the output of saving the XmlDocument? In other words, why...

XmlRootAttribute Hide xmlns:xsi
I have xml returning from a webservice which look like so... <CiscoIPPhoneMenu xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <Title>Title</Title> <Prompt>Select A Service</Prompt> <MenuItem> <Name>name</Name> <URL>http://</URL> </MenuItem> </CiscoIPPhoneMenu> how do I make the XmlRootAttribute look like this... <CiscoIPPhoneMenu> <Title>Title</Title> <Prompt>Select A Service</Prompt> <MenuIt...

how to ignore xmlns attribute inside some xml tag?
Suppose I am having this input xml:<Event><Test></Test><Result Value="true"><Request xmlns='http://tempuri.org/AtoB.xsd' RequestID="" MessageID="" UniqueID="000172581"/><Application></Application></ Result></Event> and I want this xml output:<Event><Test></Test><Request xmlns='http:// tempuri.org/AtoB.xsd' RequestID="" MessageID="" UniqueID="000172581"/ ><Application></Application></Event> i.e removing of <Resu...

OutLook 2007 Flags nto working as expected
I see that we can Quick Click a mail item and place the default Flag for it. If you click on the e-mail when there's a flag it looks like it will mark it complete with a checkmark. This is how it should function all the time. What we see is when there is a Catogorie set for an e-mail the Quick Click flag option does not work right. If there is a catogorie set then the Quick Click Flag option will set it to checked if it has a flag or not. I have five items in my inbox. If there are no catogories set I can set the flags VIA Quick Click and it works as expected. As soon a...

Removing the xmlns attribute from the DOM
Hi, I have a requirement to remove the xmlns from the DOM in order to pass over to MS CRM 3.0 Fetch method.It seems the fetch method blows up if there is a xmlns present!?! The reason I have a xmlns present is because the Xml I am passing to CRM is a node from a bigger file that does require a xmlns and using the DOM ..OuterXml seems to set the xmlns for you automatically - which I don't want. Any help would be great. Simon. Sorry, I only just saw the other post, ignore this one! Thanks Simon. "Simon Hart" <srhartone[no spam]@yahoo.com> wrote in message news:Ow...

SelectNodes and Two XMLNS's in XML Root
Hi, This is a newbie question to XMLNS. I just finished the article on "XML Namespaces and How They Affect XPath and XSLT" by Dare Obasanjo and I'm pretty sure I understand the problem. I just don't know how to achieve the desired XPath result. I'm dealing with an XML document that has two XMLNS' in the root node (Report) and I'm ending up with 0 results using SelectNodes. If I take out both namespaces, the SelectNodes(XPathQuery) works fine. With the XMLNS' the SelectNodes(XPathQuery, nsMgr) retrieves nothing. Here's a piece of the XML doc and wha...

Writing xmlns using WriteAttributeString
I am trying to create an XML spreadsheet for use with Excel. I first saved a simple spreadsheet as an XML file, and now I am trying to recreate that file in code, using .NET 2.0. The beginning of the XML file should look like the following: <?xml version="1.0"?> <?mso-application progid="Excel.Sheet"?> <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadshee...

XslCompiledTransform adds xmlns:msxsl attribute to root node
Hi all, I use XslCompiledTranform to transform one XML file into another. In my stylesheet I use the msxsl:node-set() function, so I have a namespace import in my stylesheet. After transforming, the root node of my resulting XML file has an attribute xmlns:msxsl="urn:schemas-microsoft-com:xslt" Since the resulting XML file is being validated, this unexpected attribute generates an exception. Does anyone know how to prevent this attribute from being generated? Thanks! Joost van den Boom ...

Get rid of xmlns in schema
I am giving here all the details of my schema. (Auto geneterated class from .xsd) (There are more classes in my ContactMgmt schema) [System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42")] [System.SerializableAttribute()] [System.Diagnostics.DebuggerStepThroughAttribute()] [System.ComponentModel.DesignerCategoryAttribute("code")] [System.Xml.Serialization.XmlTypeAttribute(Namespace="http:// www.xxxx.com/ContactManagement/DataSchema.xsd")] public partial class DeviceAssignment { private string cont...