xml

Why XPath.evaluate is returning NULL?

会有一股神秘感。 提交于 2021-02-16 19:26:35
问题 When I use below code to modify an xml file I receive this error : Exception in thread "main" java.lang.NullPointerException at ModifyXMLFile.updateFile(ModifyXMLFile.java:44) at ModifyXMLFile.main(ModifyXMLFile.java:56) The error occurs at line : node.setTextContent(newValue); Am I not using xpath correctly ? Here is the code and the xml file I'm attempting to update import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import

How to have an XML tag start with a number?

假装没事ソ 提交于 2021-02-16 19:13:31
问题 I'm using ElementTree API to read and write to an XML document. When I try to add a tag that starts with a number, the XML file is no longer valid. Using import xml.etree.cElementTree as ET , I am successfully able to create the XML document, but when I try to read in the XML file again, I get a ParseError. For my purposes, it does not matter if the XML document is not well formed. I just need to be able to start a tag with a number. Any idea how to do this? This is what I have tried: from

how can i remove ns from xml in python?

可紊 提交于 2021-02-16 14:38:07
问题 I have a xml like this: <?xml version="1.0" encoding="UTF-8"?> <ns0:epp xmlns:ns0="urn:ietf:params:xml:ns:epp-1.0" xmlns:ns1="http://epp.nic.ir/ns/contact-1.0"> <ns0:command> <ns0:check> <ns1:check> <ns1:id>ex61-irnic</ns1:id> <ns1:id>ex999-irnic</ns1:id> <ns1:authInfo> <ns1:pw>1487441516170712</ns1:pw> </ns1:authInfo> </ns1:check> </ns0:check> <ns0:clTRID>TEST-12345</ns0:clTRID> </ns0:command> </ns0:epp> I want to change it with python 3 to be like this: <?xml version="1.0" encoding="UTF-8"?

pretty_print option in tostring not working in lxml

江枫思渺然 提交于 2021-02-15 11:35:17
问题 I'm trying to use the tostring method in XML to get a "pretty" version of my XML as a string. The example on the lxml site shows this example: >>> import lxml.etree as etree >>> root = etree.Element("root") >>> print(root.tag) root >>> root.append( etree.Element("child1") ) >>> child2 = etree.SubElement(root, "child2") >>> child3 = etree.SubElement(root, "child3") >>> print(etree.tostring(root, pretty_print=True)) <root> <child1/> <child2/> <child3/> </root> However my output, running those

pretty_print option in tostring not working in lxml

白昼怎懂夜的黑 提交于 2021-02-15 11:34:58
问题 I'm trying to use the tostring method in XML to get a "pretty" version of my XML as a string. The example on the lxml site shows this example: >>> import lxml.etree as etree >>> root = etree.Element("root") >>> print(root.tag) root >>> root.append( etree.Element("child1") ) >>> child2 = etree.SubElement(root, "child2") >>> child3 = etree.SubElement(root, "child3") >>> print(etree.tostring(root, pretty_print=True)) <root> <child1/> <child2/> <child3/> </root> However my output, running those

Efficient way to read large XML into dfferent node types in C#

浪尽此生 提交于 2021-02-15 07:53:27
问题 I am new to C#. I have a relatively large XML file (28MB) and am trying to parse its subtrees into several different types based on their content. Essentially, I have 6900+ Content nodes that all have to be interrogated to figure out what type they are. <Collections> <Content>..</Content> <Content>..</Content> <Content>..</Content> ... </Collections> For each Content node, the variety of nodes below it can have 1 of 3 different patterns. I have to look into the node to decide which pattern

How to add a line break to text in UI5?

淺唱寂寞╮ 提交于 2021-02-13 17:26:30
问题 The escape character \n and Unicode character \u000a will only work in JavaScript. However, I'm trying to add a line break in XML view as below. But doesn't work: <u:TimelineItem text="First Line\n SecondLine" /> 回答1: New lines in text controls can be added with the following characters: In XML views or XML fragments: Line feed : or . In combination with carriage return : or . In JS or i18n*.properties files: Line feed : \n or \u000a . In combination with carriage return : \r\n or

XSD (Xml Schema Definition)

对着背影说爱祢 提交于 2021-02-13 13:58:51
知识源自于世界,我只是一个传递者; 你帮我走过的路,我正在帮他走下去。 W3School有标准教程,网址: http://www.w3school.com.cn/schema/index.asp 下面,是本人的一些整理: ‍ 1.0、XML Schema(xsd) 是什么? ‍ XML Schema 语言也称作 XML Schema 定义(XML Schema Definition,XSD)。 实在不懂官方定义,可想成: xsd是交通法,xml是行人。 xsd(交通法)规定了红停绿行,xml(行人)需遵守xsd(交通法)的规定。 基本可以替代DTD。想要了解DTD,点击: http://www.w3school.com.cn/dtd/dtd_intro.asp ‍ 2.0、为什么要使用 XML Schema(xsd)? ‍ ‍ 你也可以不用,然后你会发现要么编译不过,要么编译过了,运行出错。 多数情况下的作用是一种校验。 例: 甲、乙公司交互,约定格式传参格式为 <password>password</password>。 甲方传<pwd>pwd</pwd>,如果没有xsd,等到交互时才发现失败。 如果有xsd,在编写程序时,就告诉你<pwd>pwd</pwd>是错的,不符合xsd规定。 ‍ ‍ 3.0、如何使用 XML Schema(xsd) ? ‍ 3.1、<schema>

DataTables Excel style based on cell class

北城余情 提交于 2021-02-11 17:49:32
问题 I'm using DataTables plugin to export a monthly calendar view; I need to set a cell style inside the excel file based on the class of the corrisponding cell in the DataTables calendar view. I know how to style the exported excel file using the customize: function( xlsx, index ) {} however I'm not able to find, in the examples I saw on the forum, a way to set the style of the excel cell based on the class of the corrispondig cell in the DataTables view. I have created my own xml style like

How to use XPath contains()

空扰寡人 提交于 2021-02-11 17:44:48
问题 My XML <r> <ul> <li>ModelA</li> <bi>Foo</bi> </ul> <ul> <li>ModelB</li> <bi>boo</bi> </ul> </r> For specific node value I want to extract the value of the successor node. Example when li = ModelA get the value of bi which is Foo My Xpath : //ul[li[contains(.,'ModelA')]] 回答1: Your XPath does not contain bi , so it will not select a bi -Node. Start with //ul/bi which selects the bi -node. Now add the conditions in square brackets. The first condition is "the parent node has a li -subnode: //ul