Questions tagged [default-namespace]

XML namespace declared with no prefix, for example, `xmlns="some-uri-here"`.

declared with no prefix, for example, xmlns="some-uri-here".

Default namespace applied implicitly to elements without prefix (unprefixed elements?) i.e when default namespace declared in an unprefixed element, then that element is considered in the default namespace. Descendant elements without prefix also inherits default namespace from its ancestor. In case of multiple default namespace found among ancestor elements, default namespace from the nearest ancestor is applied.


This tag was created originally because many questions, in various programming language and platform, has been asked where the root cause of OP's confusion is the same: existence of default namespace. But even so, whenever new question comes, it isn't easy to find a good older duplicate question.

19 questions
21
votes
1 answer

Getting elements with default namespace (no namespace prefix) using XPath

In this SOAP XML file, how can I get the 7 on a using a XPath query?
user2411903
  • 221
  • 1
  • 2
  • 3
15
votes
2 answers

scrapy response.xpath returns empty array on xml document with default namespace, while response.re works

I am new to scrappy and I was playing with the scrapy shell trying to crawl this site: www.spiegel.de/sitemap.xml I did it with scrapy shell "http://www.spiegel.de/sitemap.xml" and it works all fine, when i use response.body i can see the whole…
elMeroMero
  • 752
  • 6
  • 18
5
votes
1 answer

parsing xml containing default namespace to get an element value using lxml

I have a xml string like this str1 = """ http://www.example.org/sitemap_1.xml.gz 2015-07-01
Anurag Sharma
  • 4,839
  • 13
  • 59
  • 101
5
votes
3 answers

XPath and namespace specification for XML documents with an explicit default namespace

I'm struggling to get the correct combination of an XPath expression and the namespace specification as required by package XML (argument namespaces) for a XML document that has an explicit xmlns namespace defined at the top element. UPDATE Thanks…
Rappster
  • 12,762
  • 7
  • 71
  • 120
3
votes
1 answer

Powershell: XPath cannot select when element has "xmlns" tag?

I've got a very simple xml, as below: today 10 tomorrow 90
vik santata
  • 2,989
  • 8
  • 30
  • 52
2
votes
1 answer

How to get specific element in XML containg default namespace based on condition using XPath

I have an XML document, that contains execution information of my application. I want to get specific xml elements based on the given condition. For ex: XML document :
Thejesh PR
  • 935
  • 9
  • 14
2
votes
2 answers

Remove Namespace from tag

I searched in SO but I did not found nothing that solves my problem. I hope some one can help me. I am building a XML file and I need to remove the Namespace xmlns. That is my code Document xmlDocument = new Document(); Namespace ns1 =…
user2960190
  • 180
  • 1
  • 4
  • 16
2
votes
2 answers

Null return on XmlDocument.SelectSingleNode through valid xpath

I currently have the following code nsmgr = new XmlNamespaceManager(xmlDoc.NameTable); nsmgr.AddNamespace("soapenv", soapenv_namespace); nsmgr.AddNamespace("de", de_namespace); XmlNode xnEnvelope = xmlDoc.SelectSingleNode("//soapenv:Envelope",…
Ian Jowett
  • 189
  • 18
1
vote
1 answer

how to ignore default namespace in struts2

everyone. I'm having problem on struts2 namespace.. First of all, this is my developing environment. server : tomcat (currently my project is in ROOT folder in /tomcat/webapps/ROOT) framework : struts2 Here is my problem. lets say there are two…
1
vote
1 answer

attributes in root cause xml file to not load by simplexml php

So, this is a follow-up question to my previous question that was solved, here's the link to it: using data from child element to select data in other element using simplexml in php thanks to @RomanPerekhrest for solving this. I have this piece of…
Sander Dult
  • 35
  • 1
  • 6
1
vote
1 answer

SelectSingleNode returns null even with namespace managing

I've come from this question, where my first issue was solved: XML Select a single node where the names are repeating It was a namespace issue first. But now even with the corect NameSpace managing my XPath still returns me null. I've also…
Pablo Costa
  • 125
  • 4
  • 14
1
vote
1 answer

Yahoo Sports API XML Namespace Cannot find Element

So after making queries with Yahoo's Sports API, I begin to try and parse the XML using lxml in python: I've tried getting the elements after storing them in the root,and i can access the children tags if i simply use indexing; however calling…
beast69
  • 29
  • 3
1
vote
2 answers

SelectNodes does not return the child values

I am new to XPath. I read the entire W3Schools tutorial. I would like to get all the nodes of my document. I can get all the child elements of my document with child::* but as soon as I add like the following, I get zero…
disasterkid
  • 6,948
  • 25
  • 94
  • 179
0
votes
1 answer

Why isn't one c# class in one file not finding another one defined in another file/folder?

I’m working with a new ASP.Net project in Visual Studio 2019. I’ve imported two files that play nicely together in another project, but not in this one. One file lives in the root folder and references a class that’s defined in another file, one…
0
votes
2 answers

Generic XML XPath helper with C#

Problem- I have a windows application which loads XML file and as other input takes XPath to fetch data which user wants from given XML (obviously that's not a problem). Code snippet I use to load element from given XPath is like- XPathDocument…
umarfarukhT
  • 69
  • 2
  • 6
1
2