xml-namespaces

Namespace usage in XML [duplicate]

霸气de小男生 提交于 2019-12-11 06:36:09
问题 This question already has an answer here : Pugixml - parse namespace with prefix mapping and without prefix mappig (1 answer) Closed 3 years ago . I'm parsing XML using pugi xml, which is not a namespace-aware parser (see Using Boost to read and write XML files). I'm trying to figure out how much of an issue this might be, but the problem is I don't 100% understand what XML namespaces are used for. Here is an example of some XML (that I created) that would be problematic: <Results> <Documents

CROSS APPLY to namespace, sub nodes returns duplicate records

天大地大妈咪最大 提交于 2019-12-11 05:08:46
问题 I have this xml ( removed most of it for readability ). I get wrong records. Wrong chemical names fetched for every CAS_Number . One CAS_Number means one chemical. But here, for the same CAS_number , I have different chemical names. It's the problem in my cross apply but I couldn't figure it out. <ArrayOfCatalogItem xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <CatalogItem Version="1"> <Msds xmlns="http://3ecompany.com/webservices

How do I find all text nodes in an XML document with a namespace using XPath?

天大地大妈咪最大 提交于 2019-12-11 04:32:57
问题 Suppose I have this XML: <?xml version="1.0" encoding="UTF-8"?> <root xmlns:foo="http://www.foo.com"> <foo:one>Alpha</foo:one> <two foo:Dog="Yorkie">Bravo</two> <three>foo:Delta</three> </root> If I want to use XPath to find all elements that are in the "http://www.foo.com" namespace (such as the element "one"), I can use this: //*[namespace-uri()='http://www.foo.com'] If I want to find all elements that have an attribute in that namespace (such as the element "two"), I can use this: //@*

JAXB generate xml with namespace for each element

﹥>﹥吖頭↗ 提交于 2019-12-11 04:02:06
问题 How can i generate xml with following schema using jaxb. <NS1:getRatesResponse xmlns:NS1="http://mynamespaceTypes"> <response> <NS2:rates xmlns:NS2="http://mynamespace"> <currency>USD</currency> </NS2:rates> <NS3:rates xmlns:NS3="http://mynamespace"> <currency>EUR</currency> </NS3:rates> <NS4:rates xmlns:NS4="http://mynamespace"> ... etc </response> I dont know how to tell jaxb that every new item should be NS(n+1) with the same namespace. Changing xml format is not an option,because it`s

xsl: transform namespaced tags

你说的曾经没有我的故事 提交于 2019-12-11 03:26:51
问题 I have an xsl that copies a xml file and renames the root tag. <?xml version="1.0" encoding="UTF-8"?> <xsl:stylesheet version = '1.0' xmlns:xsl='http://www.w3.org/1999/XSL/Transform' xmlns:abc="http://example.com"> <xsl:output method="xml" omit-xml-declaration="yes"/> <xsl:template match="node()|@*"> <xsl:copy> <xsl:apply-templates select="node()|@*"/> </xsl:copy> </xsl:template> <xsl:template match="root"> <test> <xsl:apply-templates select="node()|@*"/> </test> </xsl:template> <!--xsl

Updating XML with namespace with xmlstarlet 1.6.1

[亡魂溺海] 提交于 2019-12-11 02:46:46
问题 I am trying to update the host-slave.xml from a Wildfly Cluster configuration with xmlstarlet. I am using the following statement: xml ed -N my=urn:jboss:domain:2.2 -u "_:host/management/security-realms/security-realm[@name='UndertowRealm']/server-identities/ssl/keystore/@path" -v "test" Wildfly\wildfly-8.2.0.Final\WildFly-HOST\configuration\host-slave.xml The namespace definition in xml: <host name="172.16.1.11" xmlns="urn:jboss:domain:2.2" > The part of the xml I want to change: <security

Python XPath lxml could not read SVG path element due to empty namespace?

天涯浪子 提交于 2019-12-11 00:57:28
问题 I have an SVG (Xml) file from which I want to select some elements. For the sake of a MCRE I have cut down the file to this <svg > <!-- xmlns:svg="http://www.w3.org/2000/svg" xmlns="http://www.w3.org/2000/svg" --> <g> <path style="fill:#19518b;fill-opacity:1;fill-rule:nonzero;stroke:none" /> <path style="fill:#a80c3d;fill-opacity:1;fill-rule:nonzero;stroke:none" /> <path style="fill:#a98b6e;fill-opacity:1;fill-rule:nonzero;stroke:none" /> </g> </svg> Where some optional namespace attributes

How to remove the xmlns:xsd attribute but keep xmlns:xsi

a 夏天 提交于 2019-12-11 00:15:24
问题 I am using the .Net XmlSerializer to serialize an object to an XML document, in a C# Windows Forms application. The root element should end up looking like: <root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="file:///C:/data//MySchema.xsd"> <!-- ... --> </root> In a partial class (to join the partial class created by xsd.exe ), I have added the following property to add the xsi:noNamespaceSchemaLocation attribute. [XmlAttribute("noNamespaceSchemaLocation

python etree with xpath and namespaces with prefix

左心房为你撑大大i 提交于 2019-12-10 21:31:19
问题 I can't find info, how to parse my XML with namespace: I have this xml: <par:Request xmlns:par="http://somewhere.net/actual"> <par:actual>blabla</par:actual> <par:documentType>string</par:documentType> </par:Request> And tried to parse it: dom = ET.parse(u'C:\\filepath\\1.xml') rootxml = dom.getroot() for subtag in rootxml.xpath(u'//par:actual'): #do something print(subtag) And got exception, because it doesn't know about namespace prefix. Is there best way to solve that problem, counting

How to query XElement with two namespaces

邮差的信 提交于 2019-12-10 20:09:23
问题 I'm trying to find the inner text value of an element using LINQ-to-XML (an XElement object). I make my service call and get an XML response back that I've successfully loaded into an XElement object. I want to extract the inner text of one of the elements - however, every time I try to do this, I get a null result. I feel like I'm missing something super-simple, but I'm fairly new to LINQ-to-XML. Any help is appreciated. I'm trying to get the inner text value of the StatusInfo/Status element