xml-namespaces

XPath and XML: Multiple namespaces

纵然是瞬间 提交于 2019-12-10 15:15:00
问题 So I have a document that looks like <a xmlns="uri1" xmlns:pre2="uri2"> <b xmlns:pre3="uri3"> <pre3:c> <stuff></stuff> <goes></goes> <here></here> </pre3:c> <pre3:d xmlns="uri4"> <under></under> <the></the> <tree></tree> </pre3:d> </b> </a> I want an xpath expression that will get me <under> . This has a namespaceURI of uri4. Right now my expression looks like: //ns:a/ns:b/pre3:d/pre4:under I have the namespace manager add 'ns' for the default namespace (uri1 in this case) and I have it

Why am I getting this error “Unbound XML namespace prefix”

孤人 提交于 2019-12-10 14:53:41
问题 I am almost finished writing a simple android application which seems to be working well. However, when I run a code analysis I am getting around 100 warnings regarding xml files The error I am recieving is 'Unbound XML namespace prefix' and 'Namespace is not bound' here is a small sample from one of my xml files:` <style name="dialog_title_style" parent="android:Widget.TextView"> <item name="android:background">@android:color/black</item> <item name="android:padding">10dp</item> </style>

Simple XML - 2 elements, same name different namespace

ぃ、小莉子 提交于 2019-12-10 14:53:35
问题 I need to parse a XML string into objects. I would use SimpleXML for it but i got an error, Duplicate annotation of name 'link' on field 'url' private java.lang.String com.example.rogedormans.xmlreader.XML.Alert.Channel.url . An sample XML with the same problem: <rss........> <channel> <title>The Title</title> <link>http://www.someurl.com</link> <description>Some description</description> <atom:link href="http://dunno.com/rss.xml" rel="self" type="application/rss+xml"/> .... .... </channel> <

Easy way to drop XML Namespaces with JavaScript?

半腔热情 提交于 2019-12-10 14:29:41
问题 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 knowing the elements and or attributes inside? 回答1: If there is no <script> tag in the code to be replaced you can try (demo) : container.innerHTML = container

How to create XML with XML::Twig containg a namespace declaration and prefixed names?

隐身守侯 提交于 2019-12-10 11:28:20
问题 I am creating a new XML document from scratch using XML::Twig. The root element should have a prefix and a namespace declaration. All children should also belong to this namespace and use this prefix. The output should be something like this: <?xml version="1.0" encoding="UTF-8" standalone="no"?> <abc:root xmlns:abc="http://www.somehost.com/abc-data/ns/5.0.0" version="5.0.0.0"> <abc:element name="myElement"> This is my element </abc:element> </abc:root> I suppose it would look somewhat like

How to remove default namespace and keep the rest of namespaces using XSLT?

时光毁灭记忆、已成空白 提交于 2019-12-10 09:02:26
问题 I have a XML file having default namespace and empty namespaces which need to be removed, while keeping the rest of namespaces. Input: <prefix:request xmlns:prefix="urn1" xmlns:foo2="urn2" xmlns="urn1"> <element1 xmlns="">version1</element1> <element2 xsi:type="prefix:requestA" xmlns=""/> ... </element1> </prefix:request> Expected output: <prefix:request xmlns:prefix="urn1" xmlns:foo2="urn2"> <element1>version1</element1> <element2 xsi:type="prefix:requestA"/> ... </element1> </prefix:request

Why does NamespaceManager not use DefaultNamespace when using no prefix in XPath

南楼画角 提交于 2019-12-10 05:31:52
问题 When I want to traverse my XmlDocument using XPath, I came unto the problem that there were many ugly namespaces in the document, so I started using a NamespaceManager along with the XPath. The XML looks like this <Workbook xmlns="urn:schemas-microsoft-com:office:spreadsheet" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns:ss="urn:schemas-microsoft-com:office:spreadsheet" xmlns:html="http://www.w3.org/TR/REC-html40"> <Worksheet ss:Name=

Declaring an attribute for a different namespace in XML Schema

喜夏-厌秋 提交于 2019-12-10 04:04:19
问题 I've been using an XML format that is a mix of different existing formats and some custom elements and attributes, and I thought I should write a schema for those custom bits. One thing I do is use custom attributes on elements in existing formats, like this: <ns1:something attA="b" attB="a" ns2:extraAtt="c"/> I understand that doing this is allowed but I cannot think how to declare my "extraAtt" in XML Schema or, worse, in a DTD. I have tried reading the specification, but it could just as

when to use a URN for xmlns

家住魔仙堡 提交于 2019-12-10 03:54:34
问题 For a "hello world" type xml document: <?xml version="1.0" encoding="UTF-8"?> <!-- see http://www.w3.org/TR/REC-xml-names/ --> <bk:book xmlns:bk="urn:loc.gov:books" xmlns:isbn="urn:ISBN:0-395-36341-6"> <bk:title>Cheaper by the Dozen</bk:title> <isbn:number>1568491379</isbn:number> </bk:book> you can arbitrarily define urn's on the fly for custom purposes? 回答1: In short, yes. You can make 'em up as you like. 回答2: I found this answer quite useful, and it led me to this article which seems to

XPath Expression returns nothing for //element, but //* returns a count

懵懂的女人 提交于 2019-12-09 18:33:51
问题 I'm using XOM with the following sample data: Element root = cleanDoc.getRootElement(); //find all the bold elements, as those mark institution and clinic. Nodes nodes = root.query("//*"); <html xmlns="http://www.w3.org/1999/xhtml" xmlns:html="http://www.w3.org/1999/xhtml"> <head> <title>Patient Information</title> </head> </html> The following element returns many elements (from real data): //* but something like //head Returns nothing. If I run through the children of the root, the numbers