[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

xml serialization class is not working with colon in element tag

Posted on 2011-03-08
8
Medium Priority
?
1,258 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 1000 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

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

Parsing a CSV file is a task that we are confronted with regularly, and although there are a vast number of means to do this, as a newbie, the field can be confusing and the tools can seem complex. A simple solution to parsing a customized CSV fi…
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
In response to a need for security and privacy, and to continue fostering an environment members can turn to for support, solutions, and education, Experts Exchange has created anonymous question capabilities. This new feature is available to our Pr…
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…

656 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