Its the first thing passed to the XDocument constructor:
XDocument doc = new XDocument(
new XDocumentType("cXML", null,
"http://xml.cXML.org/schemas/cXML/1.2.009/cXML.dtd", null),
... but you probably want to include a XDeclaration before this.
On Thu, Nov 25, 2010 at 12:03 PM, Anthony <[email protected]> wrote:
> The below code works but how do you add this to it ie <!DOCTYPE cXML
> SYSTEM "http://xml.cXML.org/schemas/cXML/1.2.009/InvoiceDetail.dtd">
>
>
>
> *From:* [email protected] [mailto:
> [email protected]] *On Behalf Of *Matt Siebert
> *Sent:* Thursday, 25 November 2010 10:30 AM
> *To:* ozDotNet
> *Subject:* Re: Multiline Text in source code
>
>
>
> For XML I'd probably do something like...
>
>
>
> string payloadId = "123";
>
> string timestamp = DateTime.Now.ToString("yyyy-MM-dd
> HH:mm:ss.fff");
>
> XDocument doc = new XDocument(
>
> new XDocumentType("cXML", null,
> "http://xml.cXML.org/schemas/cXML/1.2.009/cXML.dtd", null),
>
> new XElement("cXML",
>
> new XAttribute("payloadID", payloadId),
>
> new XAttribute("timestamp", timestamp),
>
> //new XAttribute("xml:lang", "en-US"), // Errors
> - doesn't like the ':'
>
> new XElement("Response",
>
> new XElement("Status",
>
> new XAttribute("code", "200"),
>
> new XAttribute("text", "Successful received
> purchase order..thank you")
>
> )
>
> )
>
> )
>
> );
>
> Sorry, I'm not sure how this translates to VB (I know LINQ to XML is
> supposed to be better in VB).
>
>
>
> Also, if you really want to just work with the document as a string then
> you can surround attribute values with single quotes (see
> here<http://www.w3schools.com/xml/xml_attributes.asp>
> ):
>
>
>
> string status = "<Status code='200' text='Successful received
> purchase order..thank you' />";
>
> Of course you'd still need to escape quotes within attribute values.
>
>
>
> Cheers.
>
>
>
> On Wed, Nov 24, 2010 at 10:37 PM, Anthony <[email protected]> wrote:
>
> How do people normally handle a long text string that you create in code
>
> This is what i normally do but was hoping this is an obsolete technique? I
> hate having to esacpe the characters eg the double quotes within the
> quotes!
>
>
>
> POAck.AppendLine("<?xml version=""1.0""
> encoding=""UTF-8""?>")
>
> POAck.AppendLine("<!DOCTYPE cXML SYSTEM ""
> http://xml.cXML.org/schemas/cXML/1.2.009/cXML.dtd"">")
>
> POAck.AppendLine("<cXML payloadID=""" & Payloadid & """
> timestamp=""" & TimeStamp & """ xml:lang=""en-US"">")
>
> POAck.AppendLine("<Response>")
>
> POAck.AppendLine("<Status code=""200""
> text=""Successful received purchase order..thank you""/>")
>
> POAck.AppendLine("</Response>")
>
> POAck.AppendLine("</cXML>")
>
> regards
>
> Anthony (*12QWERNB*)
>
>
>
>
>