Use XML Literals in C#?

XML literals are a feature of VB.NET, not C#. What you have posted is as close as you can get in C#. You may want to consider replacing the embedded double quotes with single quotes though (as both types are valid XML). For larger amounts of XML you may want to consider the answer from … Read more

How can I send SOAP XML via Curl and PHP?

Thanx a lot buddy, your code has worked for me. Here is the code: $soap_do = curl_init(); curl_setopt($soap_do, CURLOPT_URL, $url ); curl_setopt($soap_do, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($soap_do, CURLOPT_TIMEOUT, 10); curl_setopt($soap_do, CURLOPT_RETURNTRANSFER, true ); curl_setopt($soap_do, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($soap_do, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($soap_do, CURLOPT_POST, true ); curl_setopt($soap_do, CURLOPT_POSTFIELDS, $post_string); curl_setopt($soap_do, CURLOPT_HTTPHEADER, array(‘Content-Type: text/xml; charset=utf-8’, ‘Content-Length: ‘.strlen($post_string) )); curl_setopt($soap_do, CURLOPT_USERPWD, $user … Read more

Serializing a list of Key/Value pairs to XML

KeyValuePair is not serializable, because it has read-only properties. Here is more information(thanks to Thomas Levesque). For changing the generated name use the [XmlType] attribute. Define your own like this: [Serializable] [XmlType(TypeName=”WhateverNameYouLike”)] public struct KeyValuePair<K, V> { public K Key { get; set; } public V Value { get; set; } }

XPathSelectElement always returns null

When namespaces are used, these must be used in the XPath query also. Your XPath query would only work against elements with no namespace (as can be verified by removing the namespace from your XML). Here’s an example showing how you create and pass a namespace manager: var xml = … XML from your post … Read more

There is no Unicode byte order mark. Cannot switch to Unicode

The reality of your file’s encoding appears to conflict with that specified by your XML declaration. If your file actually uses one-byte characters, declaring encoding=”utf-16″ won’t change it to use two-byte characters, for example. Try removing the conflicting encoding from the XML declaration. Replace <?xml version=”1.0″ encoding=”utf-16″?> with <?xml version=”1.0″?> You may also be able … Read more

How to generate JAXB classes from just XML

There are many tools available (a quick google search should fetch you some) that can generate XSD from XML assuming string type for almost everything. You should be able to use that XSD to run JAXB to get classes. Here’s an online tool that lets you do that. And here is a screen cap:

Use xml.etree.ElementTree to print nicely formatted xml files [duplicate]

You can use the function toprettyxml() from xml.dom.minidom in order to do that: def prettify(elem): “””Return a pretty-printed XML string for the Element. “”” rough_string = ElementTree.tostring(elem, ‘utf-8’) reparsed = minidom.parseString(rough_string) return reparsed.toprettyxml(indent=”\t”) The idea is to print your Element in a string, parse it using minidom and convert it again in XML using the … Read more