473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

XPathDocument and hex 0x1A

CV
I am trying to extract specific fields out of XML documents using
XPathDocument & Xpath. The basic code outline is as follows:

try {

...//Load file as XpathDocument ..

XPathDocument xp = new XPathDocument(filename, System.Xml.XmlSpace.None);

//Select the required nodes..

....

}

catch(Exception e)

{

errlog.WriteLine("\nERROR :{0}", e.Message);

errlog.WriteLine("ERROR TARGETSITE: {0}", e.TargetSite);

errlog.WriteLine("ERROR SOURCE: {0}", e.Source);

}

While processing some of those files, I get an error. The error (from the
catch statement) is as follows:

ERROR: '', hexadecimal value 0x1A, is an invalid character. Line 1, position
31425.

ERROR TARGETSITE: Int32 ScanContent()

ERROR SOURCE: System.Xml

The input XML files are generated by software from a third-party vendor. Is
there a way to ignore the 0x1A character? How can I continue processing such
files? Is there some property of XPathDocument that allows you to bypass
these characters? I looked in MSDN/Google, but couldn't find anything.

All suggestions/help appreciated.

thanks!



Nov 12 '05 #1
1 5472
0x1A is not a valid character for an XML document, so the file is not an XML
document. Legal characters below 0x20 are:
0x9, 0xA, 0xD

See:
http://www.w3.org/TR/2004/REC-xml-20040204/#charsets

--
Mickey Williams
Author, "Microsoft Visual C# .NET Core Reference", MS Press
www.servergeek.com

"CV" <cv@notavalidaddress.com> wrote in message
news:N9********************@adelphia.com...
I am trying to extract specific fields out of XML documents using
XPathDocument & Xpath. The basic code outline is as follows:

try {

..//Load file as XpathDocument ..

XPathDocument xp = new XPathDocument(filename, System.Xml.XmlSpace.None);

//Select the required nodes..

...

}

catch(Exception e)

{

errlog.WriteLine("\nERROR :{0}", e.Message);

errlog.WriteLine("ERROR TARGETSITE: {0}", e.TargetSite);

errlog.WriteLine("ERROR SOURCE: {0}", e.Source);

}

While processing some of those files, I get an error. The error (from the
catch statement) is as follows:

ERROR: '', hexadecimal value 0x1A, is an invalid character. Line 1, position 31425.

ERROR TARGETSITE: Int32 ScanContent()

ERROR SOURCE: System.Xml

The input XML files are generated by software from a third-party vendor. Is there a way to ignore the 0x1A character? How can I continue processing such files? Is there some property of XPathDocument that allows you to bypass
these characters? I looked in MSDN/Google, but couldn't find anything.

All suggestions/help appreciated.

thanks!


Nov 12 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: xmlguy | last post by:
I believe this should be pretty elementary, but for some reason I cannot seem to think of how to write the an XML file from an incoming XML file. Basically this is what I do: Input: ...
2
by: xmlguy | last post by:
Cant seem to solve this problem I need to be able to re-use XmlReader and XPathDocument for an XSLT Transform. Basically I have defined following interfaces: Class Render (Common and...
2
by: D | last post by:
Hi, I am trying to instantiate an instance of XPathDocument after serializing XML into a memory stream. Here is my method that uses XmlSerializer public MemoryStream...
8
by: Keith Chadwick | last post by:
My problem is this. I have to create several xmlReader objects each retrieving 'for xml' formatted sql server data. I then need to peice them together into a single document and place them into a...
2
by: Robert Strickland | last post by:
I load an xml stream into a xpathdocument type, compile a xpath expression and select to specific node. I find the node and wish to return the innerxml of that node. When I use value of the current...
2
by: steve bull | last post by:
I have an XPathDocument which contains a list of color definitions. If I want to add a new color definition to, or delete an existing one from, the source xml file how can I force this to be...
0
by: Joe Pannone | last post by:
I need a way to allow a variable to equal an xml document. When using xpathdocument the parameter is asking for a filename. Since I plan on doing a lot of search in the xml document I would like...
2
by: Tony Girgenti | last post by:
Hello. I'm developing a web comsuming client using VS.NET 2003(VB), .NET Framework 1.1.4322, ASP.NET 1.1.4322, WSE2.0 on a WinXP Pro Sp2 computer. I'm getting an XML document this way: Dim...
5
by: =?Utf-8?B?TWFyaw==?= | last post by:
Hi... I've been trying to improve the performance of our xml handling, so I've been doing some timing tests lately and ran across something I thought odd - XPathDocument seems slightly slower...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.