XmlSerializer: deserialize against xsd generated class 
July 21st, 2008, 06:45 PM
| | | |
Hi,
I have a schema that has an optional element, fieldTag4000Field. If the
element is omitted from the XML request, when it is deserialized, it will be
null when I check it - which is fine.
What happens when the element is supplied as <fieldTag4000Field/(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
Is there a way to alter the behavior so when I deserialize it, it is null?
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
Thanks.
The following C# class snippet was generated by xsd.exe V2:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageType {
private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
get {
return this.fieldTag4000Field;
}
set {
this.fieldTag4000Field = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageTypeFieldTag4000 {
private IDType_Type intermediaryIDCodeField;
private bool intermediaryIDCodeFieldSpecified;
private string intermediaryIdentifierField;
public IDType_Type IntermediaryIDCode {
get {
return this.intermediaryIDCodeField;
}
set {
this.intermediaryIDCodeField = value;
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IntermediaryIDCodeSpecified {
get {
return this.intermediaryIDCodeFieldSpecified;
}
set {
this.intermediaryIDCodeFieldSpecified = value;
}
}
public string IntermediaryIdentifier {
get {
return this.intermediaryIdentifierField;
}
set {
this.intermediaryIdentifierField = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
public enum IDType_Type {
B,
C,
D,
F,
U,
} | 
July 22nd, 2008, 08:15 AM
| | | | re: XmlSerializer: deserialize against xsd generated class
Unless you want to implement IXmlSerializable then I don't think you can do
what you want. You can specify that a null element is shown as:
<myElement xsi:nil="true"/>
rather than being omitted entirely by adding the XmlElement(IsNullable =
true) attribute to the field/property.
--
Joe Fawcett (MVP - XML) http://joe.fawcett.name
"j.a. harriman" <jeffrey_no_spam_alias@nospam.nospamwrote in message
news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com... Quote:
Hi,
>
I have a schema that has an optional element, fieldTag4000Field. If the
element is omitted from the XML request, when it is deserialized, it will
be
null when I check it - which is fine.
>
What happens when the element is supplied as <fieldTag4000Field/(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
>
Is there a way to alter the behavior so when I deserialize it, it is null?
>
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
>
Thanks.
>
The following C# class snippet was generated by xsd.exe V2:
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageType {
>
private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
>
public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
get {
return this.fieldTag4000Field;
}
set {
this.fieldTag4000Field = value;
}
}
}
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageTypeFieldTag4000 {
>
private IDType_Type intermediaryIDCodeField;
>
private bool intermediaryIDCodeFieldSpecified;
>
private string intermediaryIdentifierField;
>
public IDType_Type IntermediaryIDCode {
get {
return this.intermediaryIDCodeField;
}
set {
this.intermediaryIDCodeField = value;
}
}
>
>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IntermediaryIDCodeSpecified {
get {
return this.intermediaryIDCodeFieldSpecified;
}
set {
this.intermediaryIDCodeFieldSpecified = value;
}
}
>
>
public string IntermediaryIdentifier {
get {
return this.intermediaryIdentifierField;
}
set {
this.intermediaryIdentifierField = value;
}
}
}
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
public enum IDType_Type {
>
B,
>
C,
>
D,
>
F,
>
U,
}
>
| | 
July 22nd, 2008, 09:45 PM
| | | | re: XmlSerializer: deserialize against xsd generated class
Thanks for the answer Joe.
I also found some examples of using a style sheet and doing a transformation
(Using XslCompiledTransform) of the original XmlDocument. I've run a test
and it seems to work in that the result is as if the original message hadn't
had them in there. Are there any reasons why not to implement this?
Also, I tried to locate good "beginner" examples of using IXmlSerializable
that might be similar to what I need to do, but came up short. I would like
to to look at this in further detail.
Do you have any links to examples or are you aware if any of the Microsoft
example downloads (such as SDK) have any?
Thanks. Jeff
"Joe Fawcett" wrote: Quote:
Unless you want to implement IXmlSerializable then I don't think you can do
what you want. You can specify that a null element is shown as:
<myElement xsi:nil="true"/>
rather than being omitted entirely by adding the XmlElement(IsNullable =
true) attribute to the field/property.
>
--
>
Joe Fawcett (MVP - XML)
> http://joe.fawcett.name
>
"j.a. harriman" <jeffrey_no_spam_alias@nospam.nospamwrote in message
news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com... Quote:
Hi,
I have a schema that has an optional element, fieldTag4000Field. If the
element is omitted from the XML request, when it is deserialized, it will
be
null when I check it - which is fine.
What happens when the element is supplied as <fieldTag4000Field/(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
Is there a way to alter the behavior so when I deserialize it, it is null?
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
Thanks.
The following C# class snippet was generated by xsd.exe V2:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageType {
private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
get {
return this.fieldTag4000Field;
}
set {
this.fieldTag4000Field = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageTypeFieldTag4000 {
private IDType_Type intermediaryIDCodeField;
private bool intermediaryIDCodeFieldSpecified;
private string intermediaryIdentifierField;
public IDType_Type IntermediaryIDCode {
get {
return this.intermediaryIDCodeField;
}
set {
this.intermediaryIDCodeField = value;
}
}
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IntermediaryIDCodeSpecified {
get {
return this.intermediaryIDCodeFieldSpecified;
}
set {
this.intermediaryIDCodeFieldSpecified = value;
}
}
public string IntermediaryIdentifier {
get {
return this.intermediaryIdentifierField;
}
set {
this.intermediaryIdentifierField = value;
}
}
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d", "2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
public enum IDType_Type {
B,
C,
D,
F,
U,
}
| >
>
>
| | 
July 23rd, 2008, 08:05 AM
| | | | re: XmlSerializer: deserialize against xsd generated class
Jeff
IXmlSerializable is reasonably straightforward.
The newer version needs three methods, ReadXml, WriteXml and one to find the
Schema which is pointed to by an attribute, I normally just include the
schema as an embedded resource.
In ReadXml you get an XmlReader containing the XML and use it to populate
the object's fields, either reading it directly or loading it into a
DomDocumnt/XPathDocument if that's easier. WriteXml takes the fields and
creates an XML document.
There is an example here: http://www.devx.com/dotnet/Article/29720
--
Joe Fawcett (MVP - XML) http://joe.fawcett.name
"j.a. harriman" <jeffrey_no_spam_alias@nospam.nospamwrote in message
news:046D4993-D7DE-405A-814C-F5B86AC29005@microsoft.com... Quote:
Thanks for the answer Joe.
>
I also found some examples of using a style sheet and doing a
transformation
(Using XslCompiledTransform) of the original XmlDocument. I've run a test
and it seems to work in that the result is as if the original message
hadn't
had them in there. Are there any reasons why not to implement this?
>
Also, I tried to locate good "beginner" examples of using IXmlSerializable
that might be similar to what I need to do, but came up short. I would
like
to to look at this in further detail.
>
Do you have any links to examples or are you aware if any of the Microsoft
example downloads (such as SDK) have any?
>
Thanks. Jeff
>
"Joe Fawcett" wrote:
> Quote:
>Unless you want to implement IXmlSerializable then I don't think you can
>do
>what you want. You can specify that a null element is shown as:
><myElement xsi:nil="true"/>
>rather than being omitted entirely by adding the XmlElement(IsNullable =
>true) attribute to the field/property.
>>
>--
>>
>Joe Fawcett (MVP - XML)
>>
>http://joe.fawcett.name
>>
>"j.a. harriman" <jeffrey_no_spam_alias@nospam.nospamwrote in message
>news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com... Quote:
Hi,
>
I have a schema that has an optional element, fieldTag4000Field. If
the
element is omitted from the XML request, when it is deserialized, it
will
be
null when I check it - which is fine.
>
What happens when the element is supplied as <fieldTag4000Field/>
(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
>
Is there a way to alter the behavior so when I deserialize it, it is
null?
>
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
>
Thanks.
>
The following C# class snippet was generated by xsd.exe V2:
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageType {
>
private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
>
public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
get {
return this.fieldTag4000Field;
}
set {
this.fieldTag4000Field = value;
}
}
}
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageTypeFieldTag4000 {
>
private IDType_Type intermediaryIDCodeField;
>
private bool intermediaryIDCodeFieldSpecified;
>
private string intermediaryIdentifierField;
>
public IDType_Type IntermediaryIDCode {
get {
return this.intermediaryIDCodeField;
}
set {
this.intermediaryIDCodeField = value;
}
}
>
>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IntermediaryIDCodeSpecified {
get {
return this.intermediaryIDCodeFieldSpecified;
}
set {
this.intermediaryIDCodeFieldSpecified = value;
}
}
>
>
public string IntermediaryIdentifier {
get {
return this.intermediaryIdentifierField;
}
set {
this.intermediaryIdentifierField = value;
}
}
}
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
public enum IDType_Type {
>
B,
>
C,
>
D,
>
F,
>
U,
}
>
| >>
>>
>>
| | | 
July 30th, 2008, 03:35 PM
| | | | re: XmlSerializer: deserialize against xsd generated class
Hi Jeff
The code produced by xsd.exe, copes well with simple schema's, but if
your working against anything a bit complicated then it can cause
issues.
If you continue to have problems then I suggest you take a look at
Liquid XML Data Binder http://www.liquid-technologies.com/P...taBinding.aspx
This supports much more of the xsd standard, and the objects are more
strongly typed (it also comes with a free XSD editor).
Hope this helps
Regards Simon
On 23 Jul, 08:00, "Joe Fawcett" <joefawc...@newsgroup.nospamwrote: Quote:
Jeff
>
IXmlSerializable is reasonably straightforward.
The newer version needs three methods, ReadXml, WriteXml and one to find the
Schema which is pointed to by an attribute, I normally just include the
schema as an embedded resource.
In ReadXml you get an XmlReader containing the XML and use it to populate
the object's fields, either reading it directly or loading it into a
DomDocumnt/XPathDocument if that's easier. WriteXml takes the fields and
creates an XML document.
There is an example here:http://www.devx.com/dotnet/Article/29720
>
--
>
Joe Fawcett (MVP - XML)http://joe.fawcett.name
>
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
>
news:046D4993-D7DE-405A-814C-F5B86AC29005@microsoft.com...
>
>
> Quote: |
Thanks for the answer Joe.
| > Quote:
I also found some examples of using a style sheet and doing a
transformation
(Using XslCompiledTransform) of the original XmlDocument. *I've run atest
and it seems to work in that the result is as if the original message
hadn't
had them in there. *Are there any reasons why not to implement this?
| > Quote:
Also, I tried to locate good "beginner" examples of using IXmlSerializable
that might be similar to what I need to do, but came up short. *I would
like
to to look at this in further detail.
| > Quote:
Do you have any links to examples or are you aware if any of the Microsoft
example downloads (such as SDK) have any?
| >>> Quote: Quote:
Unless you want to implement IXmlSerializable then I don't think you can
do
what you want. You can specify that a null element is shown as:
<myElement xsi:nil="true"/>
rather than being omitted entirely by adding the XmlElement(IsNullable=
true) attribute to the field/property.
| | >>>> Quote: Quote:
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
>news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com...
Hi,
| | > Quote: Quote:
I have a schema that has an optional element, fieldTag4000Field. *If
the
element is omitted from the XML request, when it is deserialized, it
will
be
null when I check it - which is fine.
| | > Quote: Quote:
What happens when the element is supplied as <fieldTag4000Field/>
(empty),
it does not equate to null. *I want to be able handle this at the
deserialization level rahter than in my edits later.
| | > Quote: Quote:
Is there a way to alter the behavior so when I deserialize it, it is
null?
| | > Quote: Quote:
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
| | >> Quote: Quote: |
The following C# class snippet was generated by xsd.exe V2:
| | > Quote: Quote:
* *[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
* *[System.SerializableAttribute()]
* *[System.Diagnostics.DebuggerStepThroughAttribute()]
* *[System.ComponentModel.DesignerCategoryAttribute("c ode")]
* *[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
* *public partial class Request_TypeMessageType {
| | > Quote: Quote: |
* * * *private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
| | > Quote: Quote:
* * * *public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
* * * * * *get {
* * * * * * * *return this.fieldTag4000Field;
* * * * * *}
* * * * * *set {
* * * * * * * *this.fieldTag4000Field = value;
* * * * * *}
* * * *}
* *}
| | > Quote: Quote:
* *[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
* *[System.SerializableAttribute()]
* *[System.Diagnostics.DebuggerStepThroughAttribute()]
* *[System.ComponentModel.DesignerCategoryAttribute("c ode")]
* *[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
* *public partial class Request_TypeMessageTypeFieldTag4000 {
| | > Quote: Quote: |
* * * *private IDType_Type intermediaryIDCodeField;
| | > Quote: Quote: |
* * * *private bool intermediaryIDCodeFieldSpecified;
| | > Quote: Quote: |
* * * *private string intermediaryIdentifierField;
| | > Quote: Quote:
* * * *public IDType_Type IntermediaryIDCode {
* * * * * *get {
* * * * * * * *return this.intermediaryIDCodeField;
* * * * * *}
* * * * * *set {
* * * * * * * *this.intermediaryIDCodeField = value;
* * * * * *}
* * * *}
| | > Quote: Quote:
* * * *[System.Xml.Serialization.XmlIgnoreAttribute()]
* * * *public bool IntermediaryIDCodeSpecified {
* * * * * *get {
* * * * * * * *return this.intermediaryIDCodeFieldSpecified;
* * * * * *}
* * * * * *set {
* * * * * * * *this.intermediaryIDCodeFieldSpecified= value;
* * * * * *}
* * * *}
| | > Quote: Quote:
* * * *public string IntermediaryIdentifier {
* * * * * *get {
* * * * * * * *return this.intermediaryIdentifierField;
* * * * * *}
* * * * * *set {
* * * * * * * *this.intermediaryIdentifierField = value;
* * * * * *}
* * * *}
* *}
| | > Quote: Quote:
* *[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
* *[System.SerializableAttribute()]
* *[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
* *public enum IDType_Type {
| | >>>>> Quote: Quote:
* * * *U,
* *}- Hide quoted text -
| | >
- Show quoted text -
| | 
July 31st, 2008, 09:35 PM
| | | | re: XmlSerializer: deserialize against xsd generated class
Simon,
Thanks for the link, I will take a look at it as it may be something we
could use.
In the meantime, I did find a code snippet that removes the "empty" nodes
but it removes ALL the empty nodes in the XML and I didn't state (earlier)
that I want to do this beginning with a particular child node only.
When I use the following XPath statement in XMLSpy's XPath Evaluator, it
locates the "empty" node mentioned in the previous posts:
/parentnode/secondchildnode//*[not(node())]
When I use the same statement in my C# code, it will not locate any empty
nodes "under" the "secondchildnode" (count = 0):
XmlNodeList element =
doc.SelectNodes("/parentnode/secondchildnode//*[not(node())]");
The plan is to loop through "element" and remove the nodes using the
"ParentNode.RemoveChild" of an XmlNode - setting it to each array element,
etc.
Any ideas as to why this is not working in .NET VS2005 2.0 framework?
Thanks.
Jeff
"Sprotty" wrote: Quote:
Hi Jeff
>
The code produced by xsd.exe, copes well with simple schema's, but if
your working against anything a bit complicated then it can cause
issues.
>
If you continue to have problems then I suggest you take a look at
Liquid XML Data Binder
> http://www.liquid-technologies.com/P...taBinding.aspx
>
This supports much more of the xsd standard, and the objects are more
strongly typed (it also comes with a free XSD editor).
>
Hope this helps
>
Regards Simon
>
On 23 Jul, 08:00, "Joe Fawcett" <joefawc...@newsgroup.nospamwrote: Quote:
Jeff
IXmlSerializable is reasonably straightforward.
The newer version needs three methods, ReadXml, WriteXml and one to find the
Schema which is pointed to by an attribute, I normally just include the
schema as an embedded resource.
In ReadXml you get an XmlReader containing the XML and use it to populate
the object's fields, either reading it directly or loading it into a
DomDocumnt/XPathDocument if that's easier. WriteXml takes the fields and
creates an XML document.
There is an example here:http://www.devx.com/dotnet/Article/29720
--
Joe Fawcett (MVP - XML)http://joe.fawcett.name
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
news:046D4993-D7DE-405A-814C-F5B86AC29005@microsoft.com... Quote: |
Thanks for the answer Joe.
| Quote:
I also found some examples of using a style sheet and doing a
transformation
(Using XslCompiledTransform) of the original XmlDocument. I've run a test
and it seems to work in that the result is as if the original message
hadn't
had them in there. Are there any reasons why not to implement this?
| Quote:
Also, I tried to locate good "beginner" examples of using IXmlSerializable
that might be similar to what I need to do, but came up short. I would
like
to to look at this in further detail.
| Quote:
Do you have any links to examples or are you aware if any of the Microsoft
example downloads (such as SDK) have any?
| Quote:
>Unless you want to implement IXmlSerializable then I don't think you can
>do
>what you want. You can specify that a null element is shown as:
><myElement xsi:nil="true"/>
>rather than being omitted entirely by adding the XmlElement(IsNullable =
>true) attribute to the field/property.
| Quote:
>"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
>>news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com...
Hi,
| Quote:
I have a schema that has an optional element, fieldTag4000Field. If
the
element is omitted from the XML request, when it is deserialized, it
will
be
null when I check it - which is fine.
| Quote:
What happens when the element is supplied as <fieldTag4000Field/>
(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
| Quote:
Is there a way to alter the behavior so when I deserialize it, it is
null?
| Quote:
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
| Quote: |
The following C# class snippet was generated by xsd.exe V2:
| Quote:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageType {
| Quote: |
private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
| Quote:
public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
get {
return this.fieldTag4000Field;
}
set {
this.fieldTag4000Field = value;
}
}
}
| Quote:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageTypeFieldTag4000 {
| Quote: |
private IDType_Type intermediaryIDCodeField;
| Quote: |
private bool intermediaryIDCodeFieldSpecified;
| Quote: |
private string intermediaryIdentifierField;
| Quote:
public IDType_Type IntermediaryIDCode {
get {
return this.intermediaryIDCodeField;
}
set {
this.intermediaryIDCodeField = value;
}
}
| Quote:
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IntermediaryIDCodeSpecified {
get {
return this.intermediaryIDCodeFieldSpecified;
}
set {
this.intermediaryIDCodeFieldSpecified = value;
}
}
| Quote:
public string IntermediaryIdentifier {
get {
return this.intermediaryIdentifierField;
}
set {
this.intermediaryIdentifierField = value;
}
}
}
| Quote:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
public enum IDType_Type {
| - Show quoted text -
| >
>
| | 
August 1st, 2008, 03:05 PM
| | | | re: XmlSerializer: deserialize against xsd generated class
You could remove the empy elements in the DOM before loading it as you
suggest.
Im not seeing a problem with that
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<parentnode><secondchildnode><b/></
secondchildnode></parentnode>");
XmlNodeList xnl = xmlDoc.SelectNodes("//*[not(node())]");
Debug.Assert(xnl.Count == 1);
or you could remove it from the object model after its been loaded
(deserialized).
If you were using Liquid XML then you may be able to add code in that
would remove the empty elements as part of the de-serialization.
Cheers Simon
On 31 Jul, 21:22, j.a. harriman <jeffrey_no_spam_al...@nospam.nospam>
wrote: Quote:
Simon,
>
Thanks for the link, I will take a look at it as it may be something we
could use.
>
In the meantime, I did find a code snippet that removes the "empty" nodes
but it removes ALL the empty nodes in the XML and I didn't state (earlier)
that I want to do this beginning with a particular child node only.
>
When I use the following XPath statement in XMLSpy's XPath Evaluator, it
locates the "empty" node mentioned in the previous posts:
/parentnode/secondchildnode//*[not(node())]
>
When I use the same statement in my C# code, it will not locate any empty
nodes "under" the "secondchildnode" (count = 0):
XmlNodeList element =
doc.SelectNodes("/parentnode/secondchildnode//*[not(node())]");
>
The plan is to loop through "element" and remove the nodes using the
"ParentNode.RemoveChild" of an XmlNode - setting it to each array element,
etc.
>
Any ideas as to why this is not working in .NET VS2005 2.0 framework?
>
Thanks.
>
Jeff
>
"Sprotty" wrote:> Quote:
The code produced by xsd.exe, copes well with simple schema's, but if
your working against anything a bit complicated then it can cause
issues.
| > Quote:
If you continue to have problems then I suggest you take a look at
Liquid XML Data Binder
| >> Quote:
This supports much more of the xsd standard, and the objects are more
strongly typed (it also comes with a free XSD editor).
| >>> Quote: |
On 23 Jul, 08:00, "Joe Fawcett" <joefawc...@newsgroup.nospamwrote: | > Quote: Quote:
IXmlSerializable is reasonably straightforward.
The newer version needs three methods, ReadXml, WriteXml and one to find the
Schema which is pointed to by an attribute, I normally just include the
schema as an embedded resource.
In ReadXml you get an XmlReader containing the XML and use it to populate
the object's fields, either reading it directly or loading it into a
DomDocumnt/XPathDocument if that's easier. WriteXml takes the fields and
creates an XML document.
There is an example here:http://www.devx.com/dotnet/Article/29720 | | >>> Quote: Quote: |
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
| | > Quote: Quote: |
>news:046D4993-D7DE-405A-814C-F5B86AC29005@microsoft.com...
| | > Quote: Quote: |
Thanks for the answer Joe.
| | > Quote: Quote:
I also found some examples of using a style sheet and doing a
transformation
(Using XslCompiledTransform) of the original XmlDocument. *I've run a test
and it seems to work in that the result is as if the original message
hadn't
had them in there. *Are there any reasons why not to implement this?
| | > Quote: Quote:
Also, I tried to locate good "beginner" examples of using IXmlSerializable
that might be similar to what I need to do, but came up short. *Iwould
like
to to look at this in further detail.
| | > Quote: Quote:
Do you have any links to examples or are you aware if any of the Microsoft
example downloads (such as SDK) have any?
| | >>> Quote: Quote:
Unless you want to implement IXmlSerializable then I don't think you can
do
what you want. You can specify that a null element is shown as:
<myElement xsi:nil="true"/>
rather than being omitted entirely by adding the XmlElement(IsNullable =
true) attribute to the field/property.
| | >>>> Quote: Quote:
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
>news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com...
Hi,
| | > Quote: Quote:
I have a schema that has an optional element, fieldTag4000Field.*If
the
element is omitted from the XML request, when it is deserialized, it
will
be
null when I check it - which is fine.
| | > Quote: Quote:
What happens when the element is supplied as <fieldTag4000Field/>
(empty),
it does not equate to null. *I want to be able handle this at the
deserialization level rahter than in my edits later.
| | > Quote: Quote:
Is there a way to alter the behavior so when I deserialize it, it is
null?
| | > Quote: Quote:
I also want to add that I am calling the "CanDeserialize" methodof the
XmlSerializer object, passing in the request as a XmlNodeReader.
| | >> Quote: Quote: |
The following C# class snippet was generated by xsd.exe V2:
| | > Quote: Quote:
* *[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
* *[System.SerializableAttribute()]
* *[System.Diagnostics.DebuggerStepThroughAttribute()]
* *[System.ComponentModel.DesignerCategoryAttribute("c ode")]
* *[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
* *public partial class Request_TypeMessageType {
| | > Quote: Quote: |
* * * *private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
| | > Quote: Quote:
* * * *public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
* * * * * *get {
* * * * * * * *return this.fieldTag4000Field;
* * * * * *}
* * * * * *set {
* * * * * * * *this.fieldTag4000Field = value;
* * * * * *}
* * * *}
* *}
| | > Quote: Quote:
* *[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
* *[System.SerializableAttribute()]
* *[System.Diagnostics.DebuggerStepThroughAttribute()]
* *[System.ComponentModel.DesignerCategoryAttribute("c ode")]
* *[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
* *public partial class Request_TypeMessageTypeFieldTag4000 {
| | > Quote: Quote: |
* * * *private IDType_Type intermediaryIDCodeField;
| | > Quote: Quote: |
* * * *private bool intermediaryIDCodeFieldSpecified;
| | > Quote: Quote: |
* * * *private string intermediaryIdentifierField;
| | > Quote: Quote:
* * * *public IDType_Type IntermediaryIDCode {
* * * * * *get {
* * * * * * * *return this.intermediaryIDCodeField;
* * * * * *}
* * * * * *set {
* * * * * * * *this.intermediaryIDCodeField = value;
* * * * * *}
* * * *}
| | > Quote: Quote:
* * * *[System.Xml.Serialization.XmlIgnoreAttribute()]
* * * *public bool IntermediaryIDCodeSpecified {
* * * * * *get {
* * * * * * * *return this.intermediaryIDCodeFieldSpecified;
* * * * * *}
* * * * * *set {
* * * * * * * *this.intermediaryIDCodeFieldSpecified = value;
* * * * * *}
* * * *}
| | > Quote: Quote:
* * * *public string IntermediaryIdentifier {
* * * * * *get {
* * * * * * * *return this.intermediaryIdentifierField;
* * * * * *}
* * * * * *set {
* * * * * * * *this.intermediaryIdentifierField = value;
* * * * * *}
* * * *}
* *}
| | > Quote: Quote:
* *[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
* *[System.SerializableAttribute()]
* *[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
* *public enum IDType_Type {
| | >>>>> Quote: Quote:
* * * *U,
* *}- Hide quoted text -
| | > | | 
August 1st, 2008, 04:55 PM
| | | | re: XmlSerializer: deserialize against xsd generated class
Building off your example, here's a respresentation of my actaul XML:
<parentnode>
<firstchildnode>
<a/>
</firstchildnode>
<secondchildnode>
<b/>
<c>
<d/>
<e>12345</e>
</c>
</secondchildnode>
</parentnode>
The XPath expression, "//*[not(node())]", removes all "empty" elements. I
need it to *only* remove "b" & "d" above. "a" would be left alone.
Thanks.
Jeff
"Sprotty" wrote: Quote:
>
You could remove the empy elements in the DOM before loading it as you
suggest.
Im not seeing a problem with that
>
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<parentnode><secondchildnode><b/></
secondchildnode></parentnode>");
XmlNodeList xnl = xmlDoc.SelectNodes("//*[not(node())]");
Debug.Assert(xnl.Count == 1);
>
or you could remove it from the object model after its been loaded
(deserialized).
>
If you were using Liquid XML then you may be able to add code in that
would remove the empty elements as part of the de-serialization.
>
Cheers Simon
>
>
On 31 Jul, 21:22, j.a. harriman <jeffrey_no_spam_al...@nospam.nospam>
wrote: Quote:
Simon,
Thanks for the link, I will take a look at it as it may be something we
could use.
In the meantime, I did find a code snippet that removes the "empty" nodes
but it removes ALL the empty nodes in the XML and I didn't state (earlier)
that I want to do this beginning with a particular child node only.
When I use the following XPath statement in XMLSpy's XPath Evaluator, it
locates the "empty" node mentioned in the previous posts:
/parentnode/secondchildnode//*[not(node())]
When I use the same statement in my C# code, it will not locate any empty
nodes "under" the "secondchildnode" (count = 0):
XmlNodeList element =
doc.SelectNodes("/parentnode/secondchildnode//*[not(node())]");
The plan is to loop through "element" and remove the nodes using the
"ParentNode.RemoveChild" of an XmlNode - setting it to each array element,
etc.
Any ideas as to why this is not working in .NET VS2005 2.0 framework?
Thanks.
Jeff
"Sprotty" wrote: Quote:
The code produced by xsd.exe, copes well with simple schema's, but if
your working against anything a bit complicated then it can cause
issues.
| Quote:
If you continue to have problems then I suggest you take a look at
Liquid XML Data Binder
| Quote:
This supports much more of the xsd standard, and the objects are more
strongly typed (it also comes with a free XSD editor).
| Quote:
On 23 Jul, 08:00, "Joe Fawcett" <joefawc...@newsgroup.nospamwrote:
Jeff
| Quote:
IXmlSerializable is reasonably straightforward.
The newer version needs three methods, ReadXml, WriteXml and one to find the
Schema which is pointed to by an attribute, I normally just include the
schema as an embedded resource.
In ReadXml you get an XmlReader containing the XML and use it to populate
the object's fields, either reading it directly or loading it into a
DomDocumnt/XPathDocument if that's easier. WriteXml takes the fields and
creates an XML document.
There is an example here:http://www.devx.com/dotnet/Article/29720 | Quote: |
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
| Quote: |
news:046D4993-D7DE-405A-814C-F5B86AC29005@microsoft.com...
| Quote: |
Thanks for the answer Joe.
| Quote:
I also found some examples of using a style sheet and doing a
transformation
(Using XslCompiledTransform) of the original XmlDocument. I've run a test
and it seems to work in that the result is as if the original message
hadn't
had them in there. Are there any reasons why not to implement this?
| Quote:
Also, I tried to locate good "beginner" examples of using IXmlSerializable
that might be similar to what I need to do, but came up short. I would
like
to to look at this in further detail.
| Quote:
Do you have any links to examples or are you aware if any of the Microsoft
example downloads (such as SDK) have any?
| Quote:
>Unless you want to implement IXmlSerializable then I don't think you can
>do
>what you want. You can specify that a null element is shown as:
><myElement xsi:nil="true"/>
>rather than being omitted entirely by adding the XmlElement(IsNullable =
>true) attribute to the field/property.
| Quote:
>"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
>>news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com...
Hi,
| Quote:
I have a schema that has an optional element, fieldTag4000Field. If
the
element is omitted from the XML request, when it is deserialized, it
will
be
null when I check it - which is fine.
| Quote:
What happens when the element is supplied as <fieldTag4000Field/>
(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
| Quote:
Is there a way to alter the behavior so when I deserialize it, it is
null?
| Quote:
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
| Quote: |
The following C# class snippet was generated by xsd.exe V2:
| Quote:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageType {
| Quote: |
private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
| Quote:
public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
get {
return this.fieldTag4000Field;
}
set {
this.fieldTag4000Field = value;
}
}
}
| Quote:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageTypeFieldTag4000 {
| Quote: |
private IDType_Type intermediaryIDCodeField;
| Quote: |
private bool intermediaryIDCodeFieldSpecified;
| Quote: |
private string intermediaryIdentifierField;
| Quote:
public IDType_Type IntermediaryIDCode {
get {
return this.intermediaryIDCodeField;
}
set {
this.intermediaryIDCodeField = value;
}
}
| Quote:
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IntermediaryIDCodeSpecified {
get {
return this.intermediaryIDCodeFieldSpecified;
}
set {
this.intermediaryIDCodeFieldSpecified = value;
}
}
| Quote:
public string IntermediaryIdentifier {
get {
return this.intermediaryIdentifierField;
}
set {
this.intermediaryIdentifierField = value;
}
}
}
| Quote:
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
public enum IDType_Type {
| | >
>
| | 
August 1st, 2008, 05:15 PM
| | | | re: XmlSerializer: deserialize against xsd generated class
I may have tried to oversimplify my example.
The "real" XML has a number of "xmlns:" entries following the "parentnode".
When I remove them & test, this statement,
"/parentnode/secondchildnode//*[not(node())]", works as I was expecting.
Is there something I need to do with adding namespaces (e.g
XmlNamespaceManager) or something else that I am unaware of?
If there are 5 namespaces in the XML do I need to add a namespace for each
one?
How are the namespaces used in the XPath statement above?
Thanks.
Jeff
"j.a. harriman" wrote: Quote:
Building off your example, here's a respresentation of my actaul XML:
<parentnode>
<firstchildnode>
<a/>
</firstchildnode>
<secondchildnode>
<b/>
<c>
<d/>
<e>12345</e>
</c>
</secondchildnode>
</parentnode>
>
The XPath expression, "//*[not(node())]", removes all "empty" elements. I
need it to *only* remove "b" & "d" above. "a" would be left alone.
>
Thanks.
>
Jeff
>
"Sprotty" wrote:
> Quote:
You could remove the empy elements in the DOM before loading it as you
suggest.
Im not seeing a problem with that
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml("<parentnode><secondchildnode><b/></
secondchildnode></parentnode>");
XmlNodeList xnl = xmlDoc.SelectNodes("//*[not(node())]");
Debug.Assert(xnl.Count == 1);
or you could remove it from the object model after its been loaded
(deserialized).
If you were using Liquid XML then you may be able to add code in that
would remove the empty elements as part of the de-serialization.
Cheers Simon
On 31 Jul, 21:22, j.a. harriman <jeffrey_no_spam_al...@nospam.nospam>
wrote: Quote:
Simon,
>
Thanks for the link, I will take a look at it as it may be something we
could use.
>
In the meantime, I did find a code snippet that removes the "empty" nodes
but it removes ALL the empty nodes in the XML and I didn't state (earlier)
that I want to do this beginning with a particular child node only.
>
When I use the following XPath statement in XMLSpy's XPath Evaluator, it
locates the "empty" node mentioned in the previous posts:
/parentnode/secondchildnode//*[not(node())]
>
When I use the same statement in my C# code, it will not locate any empty
nodes "under" the "secondchildnode" (count = 0):
XmlNodeList element =
doc.SelectNodes("/parentnode/secondchildnode//*[not(node())]");
>
The plan is to loop through "element" and remove the nodes using the
"ParentNode.RemoveChild" of an XmlNode - setting it to each array element,
etc.
>
Any ideas as to why this is not working in .NET VS2005 2.0 framework?
>
Thanks.
>
Jeff
>
"Sprotty" wrote:
Hi Jeff
>
The code produced by xsd.exe, copes well with simple schema's, but if
your working against anything a bit complicated then it can cause
issues.
>
If you continue to have problems then I suggest you take a look at
Liquid XML Data Binder
> http://www.liquid-technologies.com/P...taBinding.aspx
>
This supports much more of the xsd standard, and the objects are more
strongly typed (it also comes with a free XSD editor).
>
Hope this helps
>
Regards Simon
>
On 23 Jul, 08:00, "Joe Fawcett" <joefawc...@newsgroup.nospamwrote:
Jeff
>
IXmlSerializable is reasonably straightforward.
The newer version needs three methods, ReadXml, WriteXml and one to find the
Schema which is pointed to by an attribute, I normally just include the
schema as an embedded resource.
In ReadXml you get an XmlReader containing the XML and use it to populate
the object's fields, either reading it directly or loading it into a
DomDocumnt/XPathDocument if that's easier. WriteXml takes the fields and
creates an XML document.
There is an example here:http://www.devx.com/dotnet/Article/29720
>
--
>
Joe Fawcett (MVP - XML)http://joe.fawcett.name
>
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
>
>news:046D4993-D7DE-405A-814C-F5B86AC29005@microsoft.com...
>
Thanks for the answer Joe.
>
I also found some examples of using a style sheet and doing a
transformation
(Using XslCompiledTransform) of the original XmlDocument. I've run a test
and it seems to work in that the result is as if the original message
hadn't
had them in there. Are there any reasons why not to implement this?
>
Also, I tried to locate good "beginner" examples of using IXmlSerializable
that might be similar to what I need to do, but came up short. I would
like
to to look at this in further detail.
>
Do you have any links to examples or are you aware if any of the Microsoft
example downloads (such as SDK) have any?
>
Thanks. Jeff
>
"Joe Fawcett" wrote:
>
Unless you want to implement IXmlSerializable then I don't think you can
do
what you want. You can specify that a null element is shown as:
<myElement xsi:nil="true"/>
rather than being omitted entirely by adding the XmlElement(IsNullable =
true) attribute to the field/property.
>
--
>
Joe Fawcett (MVP - XML)
>
>http://joe.fawcett.name
>
"j.a. harriman" <jeffrey_no_spam_al...@nospam.nospamwrote in message
>news:697F7C61-82AC-4387-8F04-57D200C7C703@microsoft.com...
Hi,
>
I have a schema that has an optional element, fieldTag4000Field. If
the
element is omitted from the XML request, when it is deserialized, it
will
be
null when I check it - which is fine.
>
What happens when the element is supplied as <fieldTag4000Field/>
(empty),
it does not equate to null. I want to be able handle this at the
deserialization level rahter than in my edits later.
>
Is there a way to alter the behavior so when I deserialize it, it is
null?
>
I also want to add that I am calling the "CanDeserialize" method of the
XmlSerializer object, passing in the request as a XmlNodeReader.
>
Thanks.
>
The following C# class snippet was generated by xsd.exe V2:
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageType {
>
private Request_TypeMessageTypeFieldTag4000 fieldTag4000Field;
>
public Request_TypeMessageTypeFieldTag4000 FieldTag4000 {
get {
return this.fieldTag4000Field;
}
set {
this.fieldTag4000Field = value;
}
}
}
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.ComponentModel.DesignerCategoryAttribute("c ode")]
[System.Xml.Serialization.XmlTypeAttribute(Anonymou sType=true,
Namespace="MyNamespace")]
public partial class Request_TypeMessageTypeFieldTag4000 {
>
private IDType_Type intermediaryIDCodeField;
>
private bool intermediaryIDCodeFieldSpecified;
>
private string intermediaryIdentifierField;
>
public IDType_Type IntermediaryIDCode {
get {
return this.intermediaryIDCodeField;
}
set {
this.intermediaryIDCodeField = value;
}
}
>
[System.Xml.Serialization.XmlIgnoreAttribute()]
public bool IntermediaryIDCodeSpecified {
get {
return this.intermediaryIDCodeFieldSpecified;
}
set {
this.intermediaryIDCodeFieldSpecified = value;
}
}
>
public string IntermediaryIdentifier {
get {
return this.intermediaryIdentifierField;
}
set {
this.intermediaryIdentifierField = value;
}
}
}
>
[System.CodeDom.Compiler.GeneratedCodeAttribute("xs d",
"2.0.50727.42")]
[System.SerializableAttribute()]
[System.Xml.Serialization.XmlTypeAttribute(Namespac e="MyNamespace")]
public enum IDType_Type {
>
B,
>
C,
>
D,
>
F,
>
U,
}- Hide quoted text -
>
- Show quoted text -
| | | | 
August 1st, 2008, 05:55 PM
| | | | re: XmlSerializer: deserialize against xsd generated class
j.a. harriman wrote: Quote:
The "real" XML has a number of "xmlns:" entries following the "parentnode".
When I remove them & test, this statement,
"/parentnode/secondchildnode//*[not(node())]", works as I was expecting.
>
Is there something I need to do with adding namespaces (e.g
XmlNamespaceManager) or something else that I am unaware of?
| If there are XML namespace declarations and you have elements or
attributes in those namespaces you want to select with XPath then you
indeed should use an XmlNamespaceManager and bind prefixes to the
namespace URIs to use the prefixes in your XPath expressions to qualify
element or attribute names. The XmlNamespaceManager is then passed as
the second argument to the SelectNodes or SelectSingleNode calls.
If you need more concrete help then show us the relevant XML.
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/ |  | | | | /bytes/about
We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights.
Get the best answers to your questions from over 225,662 network members.
|