xml-namespaces

Detecting Xml namespace fast

Hello there, This may be a very trivial problem I'm trying to solve, but I'm sure there's a better way of doing it. So please go easy on me. I have a bunch of XSD files that are internal to our application, we have about 20-30 Xml files that implement datasets based off those XSDs. Some Xml files are small (<100Kb), others are about 3-...

.NET and XML: How can I read nested namespaces (<abc:xyz:name attr="value"/>)?

Suppose there is an element in XML data: <abc:xyz:name attr="value"/> I'm trying to read it with XmlReader. The problem is that I get XmlException that says The ‘:’ character, hexadecimal value 0x3A, cannot be included in a name I have already declared "abc" namespace. I have also tried adding "abc:xyz" and "xyz" namespaces. But t...

Cannot add namespace prefix to children using XSL

I checked many answers here and I think I am almost there. One thing that is bugging me (and for some reason my peer needs it) follows: I have the following input XML: <?xml version="1.0" encoding="utf-8"?> <MyRoot> <MyRequest CompletionCode="0" CustomerID="9999999999"/> <List TotalList="1"> <Order CustomerID="999999999" OrderN...

Java+DOM: How do I convert a DOM tree without namespaces to a namespace-aware DOM tree?

Hello, everyone! I receive a Document (DOM tree) from a certain API (not in JDK). Sadly, this Document is not namespace-aware. As far as I know DOM, once generated, namespace-awareness can't be "added" afterwards. When converting this Document using a Transformer to a string, the XML is correct. Elements have xmlns:... attributes and n...

How can I handle an empty namespace with XDocument.XPathEvaluate?

I'm trying to use XDocument and XPathEvaluate to get values from the woot.com feed. I'm handling other namespaces fine, but this example is giving me problems. <rss xmlns:a10="http://www.w3.org/2005/Atom" version="2.0"> <channel> <category text="Comedy" xmlns="http://www.itunes.com/dtds/podcast-1.0.dtd"&gt; </cate...

XMLOutputStream, repairing namespaces, and attributes without namespaces

A simple task: write an element two attributes: String nsURI = "http://example.com/"; XMLOutputFactory outF = XMLOutputFactory.newFactory(); outF.setProperty(XMLOutputFactory.IS_REPAIRING_NAMESPACES, true); XMLStreamWriter out = outF.createXMLStreamWriter(System.out); out.writeStartElement(XMLConstants.DEFAULT_NS_PREFIX, "element", nsUR...

Making lxml.objectify ignore xml namespaces?

So I gotta deal with some xml that looks like this: <ns2:foobarResponse xmlns:ns2="http://api.example.com"&gt; <duration>206</duration> <artist> <tracks>...</tracks> </artist> </ns2:foobarResponse> I found lxml and it's objectify module, that lets you traverse a xml document in a pythonic way, like a dictionary. Problem is: ...

Namespaces and deserialization issue

UPDATE: You can run the code at the end of this to recreate and see the error I am having and hopefully solve it! UPDATE2: It's not the removal of the xmlns="" that's the issue... as you can remove it from the initial xml string. The problem is with the [XmlType(TypeName = "Systems")] somehow causing it to be added... UPDATE3: Turns ...

How to set namespace only on first tag with XOM?

I am using XOM to build XML documents in Java. I have created a simple XML document, and I want an XML namespace. But when I set the namespace on the first tag, an empty namespace is set on the childs like xmlns="", how can I get rid of this behaviour? I only want xmlns on the first tag. I want this XML: <request xmlns="http://my-name...

How to create and use XML namespace?

I want a page like this: <?xml version="1.0" encoding="UTF-8"?> <html xmlns="http://www.w3.org/1999/xhtml" xmlns:m="mine.xsd"> <m:dialog m:title="Hello">Hi there!</m:dialog> </html> How can I write "mine.xsd"? Thanks! ...

XML DOM conflicting namespace issues

Hi, I am using XML DOM documents with two namespaces. For example, consider the following document: <entry xmlns="http://www.w3.org/2005/Atom" xmlns:libx="http://libx.org/xml/libx2"&gt; <id>5</id> <title>Put Google Book results into Addison</title> <updated>2009-02-23T10:12:15Z</updated> <author> <name>LibX Team</name> ...

XML Default namespaces for unqualified attribute names?

I'm trying to understand the correct interpretation of the "Namespaces in XML 1.0 (Third Edition)" definition for unqualified attribute namespaces. "The namespace name for an unprefixed attribute name always has no value." And later in the same section: "The attribute value in a default namespace declaration MAY be empty. This ...

XML and Python: Get the namespaces declared in root element

How do I access the multiple xmlns declarations at the root element of an XML tree? For example: import xml.etree.cElementTree as ET data = """<root xmlns:one="http://www.first.uri/here/" xmlns:two="http://www.second.uri/here/"&gt; ...all other child elements here... </root>""" tree = ET.f...

XML + XPATH: Any way to work with a default Namespace?

I have a XML SOAP result: <?xml version="1.0" encoding="utf-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt; <soap:Body> <CreateCIInStockResponse xmlns="http://somenamespace.com/"&gt; ...

Trouble using namespace in SQL Server XML Data Type query

For background see this question: http://stackoverflow.com/questions/1415003/sql-server-xml-data-type-query-issue I'm trying to query against an XML object in SQL Server 2005. The query works fine when there's no namespace defined in the XML. However, when the namespace element is there I cannot seem to get the value for a node element...

Elegant Solution to Parsing XElements in a Namespace

In a project I am working on, I just finished writing an XSD for my XML so other engineers could work on the XML easier. Along with this XSD came XML namespaces. In my current parsing code, I have been using something like this: XElement element = xmlRoot.Element(XML.ELEMENT_NAME); With XML being a class full of constants that is used...

WCF Versioning : Update Attribute Namespaces and Support Previous Namespaces

I have three WCF services (.svc) which generate .wsdl references for SOAP messages. Given that part of the namespace needs to change for all ServiceContract, OperationContract, DataContract attributes, for example [DataContract(Namespace = "http://old.com.au/types/")] to [DataContract(Namespace = "http://new.com.au/types/")] How ...

simplexml and accesing feedburner's :

I'm trying trying to use simplexml to read a feedburner xml. I can read every properties in the xml but not the keys with ':' in it. Example "feedburner:origLink". When I vardump the items, those keys with : doesn't show up. And I can't do like $s->item->feedburner:origLink. Please advise! ...

How to read an XML file with an undefined namespace with XMLReader?

I'm relatively new to parsing XML files and am attempting to read a large XML file with XMLReader. <?xml version="1.0" encoding="UTF-8"?> <ShowVehicleRemarketing environment="Production" lang="en-CA" release="8.1-Lite" xsi:schemaLocation="http://www.starstandards.org/STAR /STAR/Rev4.2.4/BODs/Standalone/ShowVehicleRemarketing.xsd"> <...

XMLReader - How to handle undeclared namespace

I'm reading a large ~300Mb gzipped XML file with XMLReader that get's automatically dumped to my server nightly (archaic, I know..) It is malformed ie, it has an undefined namespace and it's throwing an error ErrorException [ Warning ]: XMLReader::read() namespace error : Namespace prefix xsi for AttrName on NodeName is not defined ...