Click here to Skip to main content
15,886,110 members
Home / Discussions / XML / XSL
   

XML / XSL

 
QuestionCan I store media within an XML file? Pin
EvanSaunders27-Jan-10 3:42
EvanSaunders27-Jan-10 3:42 
AnswerRe: Can I store media within an XML file? Pin
SeMartens27-Jan-10 20:22
SeMartens27-Jan-10 20:22 
GeneralRe: Can I store media within an XML file? Pin
EvanSaunders31-Jan-10 21:05
EvanSaunders31-Jan-10 21:05 
GeneralRe: Can I store media within an XML file? Pin
SeMartens31-Jan-10 21:10
SeMartens31-Jan-10 21:10 
GeneralRe: Can I store media within an XML file? Pin
EvanSaunders31-Jan-10 23:40
EvanSaunders31-Jan-10 23:40 
QuestionBest practice to handle processing XML files with different schemas Pin
sking7227-Jan-10 3:01
sking7227-Jan-10 3:01 
AnswerRe: Best practice to handle processing XML files with different schemas Pin
Stuart Dootson27-Jan-10 20:33
professionalStuart Dootson27-Jan-10 20:33 
Question.net XMLSerializer - multiple namespace problem Pin
AndyPeacock27-Jan-10 2:49
AndyPeacock27-Jan-10 2:49 
Hi,

Apologies if this in the wrong place but its the first time I've posted.

I've got a problem using the .net XMLSerializer object. My experience of this is limited and I haven't worked with XML much. I'm trying to something like the following:

<Record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> 
  <Property1>blah</Property1> 
  <oai_dc:dc xmlns:oai_dc=http://www.openarchives.org/OAI/2.0/oai_dc/   xmlns:dc="http://purl.org/dc/elements/1.1/">>
    <dc:Property2>asdsd</dc:Property2> 
    <dc:Property3>asdasasdda</dc:Property3> 
  </oai_dc:dc>
</Record>


however the best I can get at the moment is

<Record xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  xmlns:oai_dc="http://www.openarchives.org/OAI/2.0/oai_dc/" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <Property1>blah</Property1> 
    <oai_dc:dc>
      <dc:Property2>asdsd</dc:Property2> 
      <dc:Property3>asdasasdda</dc:Property3> 
  </oai_dc:dc>
</Record>


The namespaces are being declared in the root element, not on the dc element as I would like.

I'm attaching the XMLSerializerNamespaces as follows:
Dim XMLNamespaces As New XmlSerializerNamespaces()
        XMLNamespaces.Add("oai_dc", "http://www.openarchives.org/OAI/2.0/oai_dc/")
        XMLNamespaces.Add("dc", "http://purl.org/dc/elements/1.1/")
        XMLNamespaces.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance")

XMLSerializer.Serialize(XMLWriter, inputObject, XMLNamespaces)


and the objects I'm using are shown below:

<XmlRoot("Record")> _
Public Class Record

    <XmlElement("Property1")> _
    Public Property1 As String

    <XmlElement("dc", Namespace:="http://www.openarchives.org/OAI/2.0/oai_dc/")> _
    Public DCMetadata As DublinCore

    Public Sub New()
        DCMetadata = New DublinCore()
    End Sub

End Class


<XmlRoot("dc", Namespace:="http://www.openarchives.org/OAI/2.0/oai_dc/")> _
Public Class DublinCore

    <XmlElement("Property2", Namespace:="http://purl.org/dc/elements/1.1/")> _
    Public Property2 As String

    <XmlElement("Property3", Namespace:="http://purl.org/dc/elements/1.1/")> _
    Public Property3 As String

    Public Sub New()

    End Sub

End Class


Is there any way to force the XMLSerializer to output the namespace declarations against an element further down the line?

Thanks for any input,

Andy

modified on Wednesday, January 27, 2010 9:17 AM

AnswerRe: .net XMLSerializer - multiple namespace problem Pin
SeMartens27-Jan-10 20:25
SeMartens27-Jan-10 20:25 
GeneralRe: .net XMLSerializer - multiple namespace problem Pin
AndyPeacock27-Jan-10 21:58
AndyPeacock27-Jan-10 21:58 
QuestionSOAP C# Tutorial/Example Pin
ffowler26-Jan-10 10:32
ffowler26-Jan-10 10:32 
AnswerRe: SOAP C# Tutorial/Example Pin
SeMartens26-Jan-10 20:43
SeMartens26-Jan-10 20:43 
GeneralRe: SOAP C# Tutorial/Example Pin
ffowler27-Jan-10 2:05
ffowler27-Jan-10 2:05 
Questionadd element unique Id XSLT Pin
mvujica18-Jan-10 5:43
mvujica18-Jan-10 5:43 
AnswerRe: add element unique Id XSLT Pin
mvujica19-Jan-10 5:13
mvujica19-Jan-10 5:13 
QuestionXML file compression Pin
dalbhide bipin18-Jan-10 1:28
dalbhide bipin18-Jan-10 1:28 
AnswerRe: XML file compression Pin
mvujica18-Jan-10 5:51
mvujica18-Jan-10 5:51 
GeneralRe: XML file compression Pin
dalbhide bipin18-Jan-10 18:18
dalbhide bipin18-Jan-10 18:18 
QuestionI need an ebay program Pin
totolcm13-Jan-10 2:26
totolcm13-Jan-10 2:26 
AnswerRe: I need an ebay program Pin
JustWorking13-Jan-10 2:43
JustWorking13-Jan-10 2:43 
GeneralRe: I need an ebay program Pin
Ashfield14-Jan-10 1:26
Ashfield14-Jan-10 1:26 
JokeRe: I need an ebay program [modified] Pin
The Man from U.N.C.L.E.14-Jan-10 6:43
The Man from U.N.C.L.E.14-Jan-10 6:43 
QuestionUsing unparsed entities in schemas Pin
rusgregor12-Jan-10 21:46
rusgregor12-Jan-10 21:46 
AnswerRe: Using unparsed entities in schemas Pin
Stuart Dootson13-Jan-10 0:26
professionalStuart Dootson13-Jan-10 0:26 
GeneralRe: Using unparsed entities in schemas Pin
rusgregor13-Jan-10 4:18
rusgregor13-Jan-10 4:18 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.