xml-namespaces

How to add an XML namespace (xmlns) when serializing an object to XML

泪湿孤枕 提交于 2019-12-22 04:05:49
问题 I'm serializing Objects to XML with the help of XStream. How do I tell XStream to insert an xmlns to the XML output of my object? As an example, I have this simple object I want to serialize: @XStreamAlias(value="domain") public class Domain { @XStreamAsAttribute private String type; private String os; (...) } How do I achieve exactly the following output with XStream? <domain type="kvm" xmlns:qemu="http://libvirt.org/schemas/domain/qemu/1.0"> <os>linux</os> </domain> 回答1: Alternatively, this

Namespace Prefixes in Wsdl (.net)

孤者浪人 提交于 2019-12-22 00:07:09
问题 Namespace prefixes in my wsdl are automatically generated: s1:, s2:, etc, how can i put a specific prefix for my namespaces? Can't find it anywhere... Do i have to override the xml serialization and add them by hand (how do i do that in .net webservices?) (i mean in .net2.0 asmx, the guys who are going to use this webservice say they need that specific prefix instead of s1: and there is nothing i can do about that..) Thank you very much! 回答1: Sorry I don't have time for a full example, but

xmlns namespace breaking lxml

生来就可爱ヽ(ⅴ<●) 提交于 2019-12-21 12:37:14
问题 I am trying to open an xml file, and get values from certain tags. I have done this a lot but this particular xml is giving me some issues. Here is a section of the xml file: <?xml version='1.0' encoding='UTF-8'?> <package xmlns="http://apple.com/itunes/importer" version="film4.7"> <provider>filmgroup</provider> <language>en-GB</language> <actor name="John Smith" display="Doe John"</actor> </package> And here is a sample of my python code: metadata = '/Users/mylaptop/Desktop/Python/metadata

Python: Ignore xmlns in elementtree.ElementTree

早过忘川 提交于 2019-12-21 07:04:48
问题 Is there a way to ignore the XML namespace in tage names in elementtree.ElementTree ? I try to print all technicalContact tags: for item in root.getiterator(tag='{http://www.example.com}technicalContact'): print item.tag, item.text And I get something like: {http://www.example.com}technicalContact blah@example.com But what I really want is: technicalContact blah@example.com Is there a way to display only the suffix (sans xmlns), or better - iterate over the elements without explicitly stating

unable to locate Spring NamespaceHandler error

。_饼干妹妹 提交于 2019-12-21 06:59:49
问题 I have been having this error for nearly a week now and im just about ready to give in. I have used Maven2 to make the BIG jar file. When I run the jar file using: java -jar someJar.jar I get this error: ERROR: [27/55/13 10:55] Launcher: org.springframework.beans.factory.parsing.BeanDefinitionParsingException: Configuration problem: Unable to locate Spring NamespaceHandler for XML schema namespace [http://www.springframework.org/schema/context] Offending resource: class path resource

The prefix “ cannot be redefined from ” to <url> within the same start element tag

妖精的绣舞 提交于 2019-12-21 06:47:04
问题 I'm trying to generate the following xml element using C#. <Foo xmlns="http://schemas.foo.com" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://schemas.foo.com http://schemas.foo.com/Current/xsd/Foo.xsd"> The problem that I'm having is that I get the exception: The prefix " cannot be redefined from " to within the same start element tag. This is my c# code: XNamespace xsi = "http://www.w3.org/2001/XMLSchema-instance"; XElement foo = new XElement("Foo", new

Validation of XML Sitemap urlset with xhtml:link inside url element

泪湿孤枕 提交于 2019-12-21 05:28:13
问题 I am trying to create a sitemap such as the below and I get this error: <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xhtml="http://www.w3.org/1999/xhtml" xhtml:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd"> <url> <loc>http://www.something.com/something</loc> <xhtml:link rel="alternate" hreflang="en-us" href="http://www.something.com/something" /> </url> </urlset>

Understanding elementFormDefault qualified/unqualified when validating xml against a WSDL (xsd schema)

狂风中的少年 提交于 2019-12-20 12:27:24
问题 I'm trying to understand the implications of elementFormDefault="qualified/unqualified" in an XML schema which is embedded in WSDL (SOAP 1.1, WSDL 1). For example I have this schema inside a WSDL: <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified" targetNamespace="http://www.example.com/library"> <xsd:element name="person"> <xsd:complexType> <xsd:sequence> <xsd:element name="name" type="xsd:string"/> </xsd:sequence> </xsd:complexType> </xsd:element> </xsd

Reference to undeclared namespace prefix when parsing MSXML

我是研究僧i 提交于 2019-12-20 10:29:51
问题 How do I solve the Reference to undeclared namespace prefix: '%s' problem with Microsoft's msxml implementation? I'm using an XML feed from a government web-site that contains values i need to parse. The xml contains namespaces: <?xml version="1.0" encoding="ISO-8859-1"?> <rdf:RDF xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns="http://purl.org/rss/1.0/" xmlns:cb="http://www.cbwiki.net/wiki/index.php/Specification_1.1" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:dcterms=

Parsing XML with multiple namespaces

随声附和 提交于 2019-12-20 06:27:02
问题 So I wanted to parse this XML: <?xml version="1.0" encoding="utf-8"?> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body> <requestContactResponse xmlns="http://webservice.foo.com"> <requestContactReturn> <errorCode xsi:nil="true"/> <errorDesc xsi:nil="true"/> <id>744</id> </requestContactReturn> </requestContactResponse> </soapenv:Body> </soapenv:Envelope>