xmlreader

DTD prohibited in xml document exception

我的未来我决定 提交于 2019-11-27 13:52:22
I'm getting this error when trying to parse through an XML document in a C# application: "For security reasons DTD is prohibited in this XML document. To enable DTD processing set the ProhibitDtd property on XmlReaderSettings to false and pass the settings into XmlReader.Create method." For reference, the exception occurred at the second line of the following code: using (XmlReader reader = XmlReader.Create(uri)) { reader.MoveToContent(); //here while (reader.Read()) //(code to parse xml doc follows). My knowledge of Xml is pretty limited and I have no idea what DTD processing is nor how to do

XmlReader - Self-closing element does not fire a EndElement event?

杀马特。学长 韩版系。学妹 提交于 2019-11-27 09:23:51
I am using XmlReader in .NET to parse an XML file using a loop: while (xml.Read()) { switch xml.NodeType { case XmlNodeType.Element: //Do something case XmlNodeType.Text: //Do something case XmlNodeType.EndElement: //Do something } } I was wondering if it was normal that the following XML code does not produce some EndElement nodes? Please note the missing space before the /> but I don't think that's the problem. <date month="November" year="2001"/> <zone name="xml"/> Is there a different NodeType or property to indicate a self-closing element? Jon Skeet No, you check it by looking at

PHP - very basic XMLReader

落花浮王杯 提交于 2019-11-27 08:44:52
问题 Because I will be parsing a very large XML file, I am trying to use XMLReader to retrieve the XML data, and use simpleXML to display. I have never used XMLreader, so I am simply trying to get a basic feel for using XMLReader. I want to display all the name and price values in the XML file, and I cannot get this code to display anything. Am I missing something? Here is the XMLReader/simpleXML code: $z = new XMLReader; $z->open('products.xml'); $doc = new DOMDocument; while ($z->read() && $z-

Validating SVG file in PHP with XMLReader

帅比萌擦擦* 提交于 2019-11-27 08:16:55
问题 I am validating a SVG document (which I believe to be valid) against the SVG spec. I'm using XMLReader in PHP, and would rather stick with that as I will be using XMLReader elsewhere; that said if there are other stream-based readers that will do this easier/better, do let me me know. OK, here's some code: // Set some values for the purpose of this example $this->path = '/Users/jon/Development/Personal/Visualised/master/test-assets/import-png.svg'; $xsdPath = '/Users/jon/Development/Personal

Replacing the innertext of an Xml node/element

≡放荡痞女 提交于 2019-11-27 07:40:40
问题 First of all this is C#. I am creating a internet dashboard for a small group of colleages in the NHS. Below is an example xml file in which I need to change the innertext of. I need to replace a specific element for example "Workshop1." Because we have a few workshops I cannot afford to use a general writer because it will replace all the information on the XML document with this one bit of code below. <?xml version="1.0" ?> <buttons> <workshop1>hello</workshop1> <url1>www.google.co.uk</url1

How can I edit my code to echo the data of child's element where my search term was found in, in XMLReader?

微笑、不失礼 提交于 2019-11-27 07:28:12
问题 I am new in XMLReader, and I think is kind of hard to find tutorials/code or something advanced to get examples. My question is how can I transform the code I have now, so if I search (through a form) the term jQuery will give me the opportunity to output the value of <info></info> (and later other elements) in every <name></name> that is found in ? This is the code that output the names of the books. <?php $reader = new XMLReader(); $reader->open("books.xml"); while ($reader->read()) {

Parsing an XML stream with no root element

回眸只為那壹抹淺笑 提交于 2019-11-27 06:37:30
问题 I need to parse a continuous stream of well-formed XML elements, to which I am only given an already constructed java.io.Reader object. These elements are not enclosed in a root element, nor are they prepended with an XML header like <?xml version="1.0"?>" , but are otherwise valid XML. Using the Java org.xml.sax.XMLReader class does not work, because the XML Reader expects to parse well-formed XML, starting with an enclosing root element. So, it just reads the first element in the stream,

PHP open gzipped XML

我怕爱的太早我们不能终老 提交于 2019-11-27 05:46:17
问题 I am struggling to read gzipped xml files in php. I did succeed in reading normal xml files, using XMLReader() like this: $xml = new XMLReader(); $xml->open($linkToXmlFile); However, this does not work when the xml file is gzipped. How can I unzip the file and read it with the XMLReader? 回答1: As you didn't specify a PHP version, I am going to assume you are using PHP5. I am wondering why people haven't suggested using the built in PHP compression streams API. $linkToXmlFile = "compress.zlib:/

Current line number from a System.Xml.XmlReader (C# & .Net)

梦想的初衷 提交于 2019-11-27 04:49:17
问题 Does anyone know how I can get the current line number of an System.Xml.XmlReader? I am trying to record where in a file I find Xml elements. 回答1: Take advantage of the IXmlLineInfo interface supported by an XmlReader : IXmlLineInfo xmlInfo = (IXmlLineInfo)reader; int lineNumber = xmlInfo.LineNumber; 回答2: Expanding on the IXmlLineInfo interface, the documentation for this is pretty bad; from doing a bit of digging, I can tell you the following: 1) System.Xml.XmlReader is abstract, so you're

There is no Unicode byte order mark. Cannot switch to Unicode

倾然丶 夕夏残阳落幕 提交于 2019-11-27 03:43:09
问题 I am writing an XML validator with XSD. Below is what I did, but when the validator reached the line while (list.Read()) it gives me the error There is no Unicode byte order mark. Cannot switch to Unicode. Can anybody help me fix it? public class Validator { public void Validate(string xmlString) { Boolean bRet = true; string xmlPath = @"C:\x.xml"; string xsdPath = @"C:\general.xsd"; XmlReaderSettings Settings = new XmlReaderSettings(); Settings.Schemas.Add("", xsdPath); Settings