xml-namespaces

How do I use xml namespaces with find/findall in lxml?

眉间皱痕 提交于 2019-11-27 05:36:11
问题 I'm trying to parse content in an OpenOffice ODS spreadsheet. The ods format is essentially just a zipfile with a number of documents. The content of the spreadsheet is stored in 'content.xml'. import zipfile from lxml import etree zf = zipfile.ZipFile('spreadsheet.ods') root = etree.parse(zf.open('content.xml')) The content of the spreadsheet is in a cell: table = root.find('.//{urn:oasis:names:tc:opendocument:xmlns:table:1.0}table') We can also go straight for the rows: rows = root.findall(

C#, XML, adding new nodes

纵饮孤独 提交于 2019-11-27 05:20:26
I am trying to add new nodes to an existing XML file. i have this file with first test elements in it: <?xml version="1.0" encoding="utf-8"?> <Root xmlns="http://prpa.org/XMLSchema1.xsd"> <studenti> <student> <ime>test</ime> <prezime>test</prezime> <ocijena>0</ocijena> </student> </studenti> <profesori> <profesor> <ime>test</ime> <prezime>test</prezime> </profesor> </profesori> </Root> I used this schema to generate this XML document <?xml version="1.0" encoding="utf-8"?> <xs:schema id="XMLSchema1" targetNamespace="http://prpa.org/XMLSchema1.xsd" elementFormDefault="qualified" xmlns="http:/

Unable to add namespace to an attribute with PHP's SimpleXML

妖精的绣舞 提交于 2019-11-27 05:09:05
I am creating an Atom feed, when I tried below to add xmlns:i as an attribute - $node->addAttribute("xmlns:i","http://www.w3.org/2001/XMLSchema-instance"); I got this as an output - i="http://www.w3.org/2001/XMLSchema-instance" "xmlns:" part was cut off. do I need to escape the : -character? Or is they any other way to add this namespace? VolkerK If you want to add an attribute from the namespace/prefix i to $node don't bother declaring the namespace beforehand. Just use the third parameter of addAttribute() to provide the namespace uri for the prefix you're using in the first parameter. $node

javax.faces.view.facelets.FaceletException: Error Parsing /my.xhtml: Error Traced[line: 42] The prefix “f” for element “f:facet” is not bound

Deadly 提交于 2019-11-27 04:51:38
问题 I would like to create table which can display data from database into JSF page. I found this code: <h:dataTable value="#{bookStore.items}" var="store"> <h:column> <f:facet name="header"> <h:outputText value="#{msg.storeNameLabel}"/> </f:facet> <h:outputText value="#{store.name}"/> </h:column> <h:column> <f:facet name="header"> Subject </f:facet> <h:outputText value="#{store.subject}"/> </h:column> <h:column> <f:facet name="header"> <h:outputText value="#{msg.storePriceLabel}"/> </f:facet> <h

How can I access namespaced XML elements using BeautifulSoup?

心不动则不痛 提交于 2019-11-27 04:49:56
问题 I have an XML document which reads like this: <xml> <web:Web> <web:Total>4000</web:Total> <web:Offset>0</web:Offset> </web:Web> </xml> my question is how do I access them using a library like BeautifulSoup in python? xmlDom.web["Web"].Total ? does not work? 回答1: BeautifulSoup isn't a DOM library per se (it doesn't implement the DOM APIs). To make matters more complicated, you're using namespaces in that xml fragment. To parse that specific piece of XML, you'd use BeautifulSoup as follows:

Why is my WCF web service presenting this object in a different namespace with different field names?

醉酒当歌 提交于 2019-11-27 04:02:12
问题 The Context: I'm trying to integrate with DocuSign's Connect notification service. I've set up a WCF service with a method called DocuSignConnectUpdate which takes a DocuSignEnvelopeInformation as its only parameter, as specified by DocuSign. This DocuSignEnvelopeInformation object comes from a reference to their API, so that they can pass this object to my web service, and I know exactly what to expect. DocuSign asks for my service address and the namespace, which I have configured on their

How to add xsi schemalocation to root c # object XmlSerializer

隐身守侯 提交于 2019-11-27 02:42:11
问题 I am using XmlSerializer to create an object representing an XML file and now i want to add a schemalocation to the rootelement of my xml file. I can add namespaces like the following XmlSerializer serializer = new XmlSerializer(typeof(MyClass)); System.IO.FileStream fs = new FileStream(@"C:\test.xml", FileMode.Create); TextWriter writer = new StreamWriter(fs, new UTF8Encoding()); XmlSerializerNamespaces ns = new XmlSerializerNamespaces(); ns.Add("xy","http://www.w3.org/2005/08/addressing");

How can I strip namespaces out of an lxml tree?

Deadly 提交于 2019-11-27 02:31:25
问题 Following on from Removing child elements in XML using python ... Thanks to @Tichodroma, I have this code: If you can use lxml, try this: import lxml.etree tree = lxml.etree.parse("leg.xml") for dog in tree.xpath("//Leg1:Dog", namespaces={"Leg1": "http://what.not"}): parent = dog.xpath("..")[0] parent.remove(dog) parent.text = None tree.write("leg.out.xml") Now leg.out.xml looks like this: <?xml version="1.0"?> <Leg1:MOR xmlns:Leg1="http://what.not" oCount="7"> <Leg1:Order> <Leg1:CTemp id="FO

Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function

天大地大妈咪最大 提交于 2019-11-27 02:07:04
问题 I am trying to call SelectNode from XmlDocument class and trouble due to this error: Namespace Manager or XsltContext needed. This query has a prefix, variable, or user-defined function. My code: public void Add(ref XmlDocument xmlFormat, String strName) { XmlDocument dom; XSLTemplate xsl = null; String strPath = ""; XmlNodeList nl; XmlAttribute na; int n; nl = (XmlNodeList)xmlFormat.SelectNodes("//xsl:import/@href",nsm); } and xsl: <xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org

Changing the default XML namespace prefix generated with JAXWS

≯℡__Kan透↙ 提交于 2019-11-27 01:37:49
I am using JAXWS to generate a WebService client for a Java Application we're building. When JAXWS build its XMLs to use in SOAP protocol, it generates the following namespace prefix: <env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"> <env:Body ...> <!-- body goes here --> </env:Body> </env:Envelope> My problem is that my Counterpart (a big money transfer company) which manages the server my client is connecting to, refuses to accept the WebService call ( please don't ask my why ) unless the XMLNS (XML namepspace prefix is soapenv ). Like this: <soapenv:Envelope xmlns:soapenv