xmlreader

Error Serializing String in WebService call

this morning I ran into an issue with returning back a text string as result from a Web Service call. the Error I was getting is below ************** Exception Text ************** System.ServiceModel.CommunicationException: Error in deserializing body of reply message for operation 'GetFilingTreeXML'. ---> System.InvalidOperationExcepti...

Abusing XmlReader ReadSubtree()

Hello. I need to parse a xml file which is practically an image of a really big tree structure, so I'm using the XmlReader class to populate the tree 'on the fly'. Each node is passed just the xml chunk it expects from its parent via the ReadSubtree() function. This has the advantage of not having to worry about when a node has consumed...

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

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 ...

Parsing through XML elements in XmlReader

Hi all, I'm building an application that needs to run through an XML feed but I'm having a little trouble with getting certain elements. I'm using the Twitter feed and want to run through all the <item> elements. I can connect fine and get the content from the feed but I can't figure out how to select only the item elements when I'm lo...

right approach to handling bad xml data

I've got a little c# windows service that periodically pulls xml from a web service and stores the data in a database table. Unfortunately it's failing because the web service has occasional bad data in it - strings instead of decimals. I don't have any control over the web service (unvalidated user input from software we can't change)...

XMLTextReader.ReadSubtree to return XMLTextReader

I am using an XMLTextReader to process an XML file (as opposed to an XMLDocument). I use XMLTextReader so I can use the option to ignore all whitespace. At certain points I want to read in a node using ReadSubtree. This returns an XMLReader. How can I convert this to a XMLTextReader so I can use the ignore whitespace option. ...

Custom Schema Validation behaviour - XmlReaderSettings

I am parsing XML with an XMLReader using a XMLReaderSettings object with the event handling setup to carry out schema validation where appropriate. However it seems that the error catching only occurs once per level of XML. This means that any subsequent errors at that level are ignored. Is there any way I can get the Error handling ev...

Reading the StackOverflow RSS feed

I'm trying to get a list of unanswered questions from the feed but am having trouble reading it. const string RECENT_QUESTIONS = "http://stackoverflow.com/feeds"; XmlTextReader reader; XmlDocument doc; // Load the feed in reader = new XmlTextReader(RECENT_QUESTIONS); //reader.MoveToContent(); // Add the feed to the document doc = new...

PHP XMLReader getting parent node?

While parsing an XML File using the XMLReader Method, how do I get the parent node of an element ? $xml = new XMLReader(); $xml->XML($xmlString); while($xml->read()) { $xml->localName; // gives tag name $xml->value; // gives tag value // how do I access the parent of this element } ...

help in reading nested xml using xmlreader in php

<root> <thing> <specs> <spec1 /> <spec3 /> <spec2 /> </specs> <details /> <more_info> <info1 /> <info2 /> </more_info> </thing> </root> okeee so i got this sample xml and the problem is i cant seem to get the values of the innerxml, when i use $reader->readInnerXML() it returns the...

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

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. ...

How to best detect encoding in XML file?

To load XML files with arbitrary encoding I have the following code: Encoding encoding; using (var reader = new XmlTextReader(filepath)) { reader.MoveToContent(); encoding = reader.Encoding; } var settings = new XmlReaderSettings { NameTable = new NameTable() }; var xmlns = new XmlNamespaceManager(settings.NameTable); var context =...

Matching ReadEndElement with ReadStartElement when using an XmlReader

My question is simple. I've been using ReadStartElement and ReadEndElement with the XmlReader in my code just fine. The question is (and this is after looking at MSDN), do you need to match the two? In other words, do I end with ReadEndElement for each and every ReadStartElement or is are there cases where you don't need so many Rea...

XML Reader on SQL Table returning invalid XML

I have SQL table that has a varchar(8) column that occasionally has binary data in it. (0x01, 0x02, etc...). (Changing the format or the content of the column isn't an option.) When I go into the SQL Server 2005 Management Studio and run the query: select * from mytable where clientID = 431620 for xml auto I get useful results...

What is the best way to parse (big) XML in C# Code?

I'm writing a GIS client tool in C# to retrieve "features" in a GML-based XML schema (sample below) from a server. Extracts are limited to 100,000 features. I guestimate that the largest extract.xml might get up around 150 megabytes, so obviously DOM parsers are out I've been trying to decide between XmlSerializer and XSD.EXE generated ...

XMLReader encoding error

I have a PHP script which is trying to parse a huge XML file. To do this I'm using the XMLReader library. During the parsing, I have this encoding error: Input is not proper UTF-8, indicate encoding ! Bytes: 0xA0 0x32 0x36 0x30 I would like to know if they are a way to skip records with bad characters. Thanks! ...

XmlReader get element default from schema

This is probably a naive question about XmlReader, but I haven't turned up an answer in the MSDN docs. Suppose that I have XSD SchemaTest.xsd <?xml version="1.0" encoding="utf-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"&gt; <xs:element name="pageSettings"> <xs:complexType> <xs:sequence> <xs:element n...

In .NET, does the entire XML blob come into memory when I validate against a XSD?

If I have a large (>500MB) XML file to validate, does an XmlReader bring the whole thing into memory to perform validation? I looked at http://stackoverflow.com/questions/751511/validating-an-xml-against-referenced-xsd-in-c for validation procedure. thanks, Mark ...

How to use XmlReader class?

I want to save and load my xml data using XmlReader. But I don't know how to use this class. Can you give me a sample code for start? ...

C# HttpWebRequest - How to disgtinguish between HTML and XML pages without downloading ?

I need to be able to tell if a link (URL) points to an XML file (RSS feed), or a regular HTML file just by looking at the headers, or something similiar (without downloading it) Any good advice for me there ? :) Thanks! Roey ...