Solved

xml serialization class is not working with colon in element tag

Posted on 2011-03-08
8
1,175 Views
Last Modified: 2012-05-11
Hello experts, I am using the xml serialization class to create a serialized xml file, within the xml i have tags that need to contain a colon.   When the xml is created the colon is replaced with _x003A_

<pre_x003A_salesorder>

<pre:salesorder>

Why is this happening and how do i fix it?
0
Comment
Question by:tentavarious
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 2
8 Comments
 
LVL 75

Accepted Solution

by:
käµfm³d   👽 earned 250 total points
ID: 35069269
In XML, the construct xxx: indicates an alias to a namespace. There should be a matching namespace declaration in your XML which defines the namespace which xxx represents. Can you post the code and a sanitized example of your XML?
0
 

Author Comment

by:tentavarious
ID: 35069472
Here is a simplified version of the xml that gets generated


<?xml version="1.0" encoding="utf-16"?>
<pre_x003A_SalesOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <DataArea>
    <Received>
      <Status>SUCCESS</Status>
    </Received>
    <Order>
      <Headinfo>
       <Note>OrderDate: 3/8/2011</Note>
      </Headinfo>
    </Order>
  </DataArea>
</pre_x003A_SalesOrder>

I cant post the xml code because it contains sensitive information but should i be looking for attribute tags like this?

System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://ourcompany.com/salesorderinfo"),  _
 System.Xml.Serialization.XmlRootAttribute("SalesOrder", [Namespace]:="http://ourcompany.com/salesorderinfo", IsNullable:=false)>  _
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 35069528
Where woudl the "pre:" be going?
0
Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

 

Author Comment

by:tentavarious
ID: 35069577
Well what the generate xml should look like is this

<pre:SalesOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <DataArea>
    <Received>
      <Status>SUCCESS</Status>
    </Received>
    <Order>
      <Headinfo>
       <Note>OrderDate: 3/8/2011</Note>
      </Headinfo>
    </Order>
  </DataArea>
</pre:SalesOrder>
0
 

Author Comment

by:tentavarious
ID: 35097589
Ok, when i go through and serialize the xml why does it put this tag on

<?xml version="1.0" encoding="utf-16"?>

instead of encoding it in utf-8  ?
0
 

Author Comment

by:tentavarious
ID: 35097828
Hey guys i found the problem, this site provided me with the answer

http://stackoverflow.com/questions/3862063/serializing-an-object-as-utf-8-xml-in-net


The default encoding must be utf-16, so switching it to uft-8 before serializing seems to have fixed the issue.
0
 

Author Comment

by:tentavarious
ID: 35108809
Ok, i still cant get this working, i am using the xsd.exe tool to create the xml serialization class based off the schema they are sending me.  Can someone point me to a tutorial that better explains what i should be doing.
0
 

Author Comment

by:tentavarious
ID: 35109018
K, could someone explain what this code should be doing?

<System.CodeDom.Compiler.GeneratedCodeAttribute("xsd", "2.0.50727.42"), _
 System.SerializableAttribute(), _
 System.Diagnostics.DebuggerStepThroughAttribute(), _
 System.ComponentModel.DesignerCategoryAttribute("code"), _
 System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://mycom.com/updatemachine"), _
 System.Xml.Serialization.XmlRootAttribute("UpdateOrder", [Namespace]:="http://mycom.com/updatemachine", IsNullable:=False)> _
Partial Public Class UpdateOrderType
end Class

I left out all the variables, this code gets created when i run the xsd.exe tool on their provided shema?   When i run this code the it creates this opening tag

<UpdateOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="<UpdateOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://mycom.com/updatemachine">


The above tag is missing the "pre:"  I am being told the above tag should look like this

<pre:UpdateOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="<UpdateOrder xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:pre="http://mycom.com/updatemachine">
0

Featured Post

Is Your Team Achieving Their Full Potential?

74% of employees feel they are not achieving their full potential. With Linux Academy, not only will you strengthen your team's core competencies but also their knowledge of of the newest IT topics.

With new material every week, we'll make sure that you stay ahead of the game.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
This video Micro Tutorial shows how to password-protect PDF files with free software. Many software products can do this, such as Adobe Acrobat (but not Adobe Reader), Nuance PaperPort, and Nuance Power PDF, but they are not free products. This vide…
In this brief tutorial Pawel from AdRem Software explains how you can quickly find out which services are running on your network, or what are the IP addresses of servers responsible for each service. Software used is freeware NetCrunch Tools (https…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question