xml-namespaces

How can I find out the namespace of an element in PHP DOM?

This sounds like a pretty easy question to answer but I haven't been able to get it to work. I'm running PHP 5.2.6. I have a DOM element (the root element) which, when I go to $element->saveXML(), it outputs an xmlns attribute: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <html xmlns="http://www.w3.org/1999/xhtml" lang="en"...

Preserving subelement namespace serialization with lxml

I have a few different XML documents that I'm trying to combine into one using lxml. The problem is that I need the result to preserve the namespaces on each of the sub-documents' root nodes. Lxml seems to want to push any namespace declarations used more than once to the root of the new document, which breaks in my application (it is ...

How to preprocess ZipInputStream of XML data before deserialization?

In .NET and C#, I have some XSD generated class with root and type attributes set to [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://example.com")] [System.Xml.Serialization.XmlRootAttribute("myRootElement", Namespace="http://example.com", IsNullable=false)] Furthermore, I have files containing XML data from different sou...

jQuery HTML namespace element click event

Hi, I have this code in my HTML document and I would life to bind click event on such elements. <gui:button id="btnTest"> <label>Compose mail</label> <click>someaction()</click> </gui:button> I tried this two methods in my document.ready function, but none of them work $('gui\:button').click(function() { alert('clicked'); }); $(...

how to remove namespace from XML root element?

Hi, is there a simple way to remove the namespace from the XML root element. I have tried with [XmlRootAttribute("MCP", Namespace = "", IsNullable = false)] on the serializable class. But no use. still getting the same result. sample class [Serializable] [XmlRootAttribute("MCP", Namespace = "", IsNullable = false)] public c...

Easy way to drop XML Namespaces with JavaScript?

Is there an easy way, for example, to drop an XML name space, but keep the tag as is with jQuery or JavaScript? For example: <html:a href="#an-example" title="Go to the example">Just an Example</html:a> And change it to: <a href="#an-example" title="Go to the example">Just an Example</a> On the fly with jQuery or JavaScript and not...

Wierdness with XDocument, XPath and namespaces

I have an XML document that looks like this: <kmsg xmlns="http://url1" xmlns:env="url1" xmlns:xsi="http://www.w3.org/2001/XMLSchemainstance" xsi:schemaLocation="http://location that does not exist.xsd"> <header> <env:envelope> <env:source branch="907" machine="0" password="J123"/> </env:envelope> </header> <body> <Or...

avoid error when xpath does not find namespace in xml

Hello everyone, Could someone tell me how to avoid these errors? Testing for existance of namespace? It starts when I want to add geo information to an array I thought it was enough to do this. (from the picasa api feed) foreach($feed->xpath('//gml:pos') as $pos) { $feed_arr['geo'][$i]['pos'] = (string)$pos[0]; $i++; } <b>Warning</...

XML Namespace error in WSDL file

I have the following service definition (incomplete, but demonstrates the error. Visual Studio tells me (translated from german) "In this Schema Namespace http://schemas.xmlsoap.org/wsdl/ is not available" at the line where I define OffertXML. <?xml version="1.0" encoding="UTF-8"?> <wsdl:definitions name="TestOffertverwaltung" targetNa...

Oracle XSLT: default namespace results in empty tags

I think the best way to ask this question is: How do I specify a default namespace for the root element in the output? Doing this: <xsl:template match="/"> <r xmlns:s"http://www.mycompany.com/s/schema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://www.mycompany.com/default/schema" > .... .... Gives me an ...

Good python XML parser to work with namespace heavy documents

Python elementTree seems unusable with namespaces. What are my alternatives? BeautifulSoup is pretty rubbish with namespaces too. I don't want to strip them out. Examples of how a particular python library gets namespaced elements and their collections are all +1. Edit: Could you provide code to deal with this real world use-case using...

Why is the namespace reference being lost when copying XML nodes?

I have an XML document (an InfoPath form) that looks similar to this: <my:ClientMaintenance xmlns:my="http://schemas.microsoft.com/office/infopath/2003/myXSD/2009-07-06T07:04:54"&gt; <my:Payments> </my:Payments> <my:Payment> <my:Amount></my:Amount> <!-- Several other nodes --> </my:Payment> </my:ClientMai...

How to detect and remove unnecessary xmlns:<something> attributes in PHP DOM?

Say I have a source document like this: <element> <subelement xmlns:someprefix="mynamespace"/> </element> The xmlns:someprefix is obviously not needed here and doesn't do anything since that namespace is not being used anywhere in the document. In PHP, after I've loaded this into a DOM tree with DOMDocument->loadXML(), I'd like to ...

Add a namespace on an xml generated by a query

I try to add a namespace on xml using WITH XMLNAMESPACES. When I execute my queries, the namespace is added with the root element but with the second element I have xmlns="" as well... and I would like to remove that... I provided an example: Queries for creating the table and the data: SET ANSI_NULLS ON GO SET QUOTED_IDENTIFIER ON G...

List all Persistence Units in persistence.xml

Hi all, I am trying to use XPath to get a list of all the persistence units in persistence.xml and am having trouble. The one that I thought would work was: //persistence/persistence-unit * The latter gives me the persistence child which is at least something, I can then manually iterate through, but that defeats the purpose of XPa...

WCF with XmlSerializer: namespace collision when returning generic contracts

The background I'm developing a REST API for a C#.NET web application using WCF. I configured it to use the XmlSerializer rather than its default DataContractSerializer, for greater control over the XML format. I created a generic ResponseContract<TResponse, TErrorCode> data contract, which wraps the response with <Api> and <Response> f...

XSLT does not work when I include xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"

My Google sitemap renders well through XSLT fine without the xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" in the < urlset > element, however when included, my foreach statement doesn't work and nothing renders in the template. My code's below. Thanks for your help. XML <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"&...

select a node with an xmlns?

I am trying to select all of the links in a xhtml document in xsl. Some of the anchor tags have the namespace declaration xmlns="http://www.w3.org/1999/xhtml" in them. These are not selected. e.g. with this xml doc: <?xml version="1.0"?> <?xml-stylesheet type="text/xsl" href="xsl.xsl"?> <root> <item> this iz sum text and it haz sum ...

Where should I put a URI declaration for a namespace in an XML doc?

I am currently building an XML schema, with a head, a body, and potentially errors. I am dividing those three parts into different namespaces, so I'm wondering where and when I should put the URI namespace declarations in. For example, should it be: <head:schema xmlns:head="http://mywebsite.com/ns/head/" xmnls:body="http://mywebsite.co...

Storing complex XML values in PHP

Consider this hypothetical xml: <myApi xmlns="urn:something" xmlns:bla="urn:hello"> <argument1>foo</argument1> <argument2> <p xmlns="http://www.w3.org/1999/xhtml"&gt;Some paragraph of text. <img src="http://www.example.org/hello.png" bla:test="oi" /></p> </argument2> </myApi> What would be the best way in PHP to parse out t...