RE: XmlNode.InnerXml and Xml Readers / XmlDocument
- From: Hermit Dave <hermitd@xxxxxxxxxxxxxxxx>
- Date: Fri, 27 Apr 2007 01:26:01 -0700
Steven,
The xml i copied was a part of a bigger xml document that does contain the
declaration for "it". However that is not the point.
What i meant was that the following characters need to be escaped as they
are xml reserved chars
>< <
" "
' '
consider the node
<DSPLY_NAME><test></DSPLY_NAME>
Use XmlTextReader or XmlValidatingReader.ReadInnerXml i correctly received
the value <test>
However if i were to use
<DSPLY_NAME><test"Invalid"></DSPLY_NAME>.
The XmlTextReader or XmlValidatingReader's ReadInnerXml() return
<test"invalid">
The same applied for any use of '.
Is there any way i can avoid the Xml Readers / Document objects from
decoding the encoded characters ?
Regards,
Hermit
--
Regards,
Hermit Dave
http://www.invokeit.co.uk
"Steven Cheng[MSFT]" wrote:
Hi Hermit,.
As for the XML character escaping issue, I'm wondering how do you to load
the XML document, is it originally store in file and you use XmlDocument to
load it into memory?
Based on my understanding, the following like XML document is an invalid
one as the '<' , '>' hasn't been escaped and when you load it through
XmlDocument class, it will report exception(also the namespace prefix "it"
need to be declared):
==============
<exlObjectFields>
<it:DSPLY_NAME><test"invalid"></it:DSPLY_NAME>
<it:OFFCL_CODE>TFMS000000</it:OFFCL_CODE>
<it:BCKGRNDPAG>TFMS000000</it:BCKGRNDPAG>
</exlObjectFields>
=============
I have performed some test wihch store the escaped XML in file(as below);
==============
<exlObjectFields xmlns:it="xxxx" >
<it:DSPLY_NAME><test"invalid"></it:DSPLY_NAME>
<it:OFFCL_CODE>TFMS000000</it:OFFCL_CODE>
<it:BCKGRNDPAG>TFMS000000</it:BCKGRNDPAG>
</exlObjectFields>
===============
After loading into XmlDocument as following, it still keep the escaped
format(< and >):
private void btnTest2_Click(object sender, EventArgs e)
{
XmlDocument doc = new XmlDocument();
doc.Load("output.xml");
MessageBox.Show(doc.OuterXml);
}
<<<<<<<<<<<<<<<<<<<
Are you also using the similar code logic? Please feel free to let me know
if there is anything I missed.
Sincerely,
Steven Cheng
Microsoft MSDN Online Support Lead
==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
ications.
Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscriptions/support/default.aspx.
==================================================
This posting is provided "AS IS" with no warranties, and confers no rights.
- Follow-Ups:
- RE: XmlNode.InnerXml and Xml Readers / XmlDocument
- From: Steven Cheng[MSFT]
- RE: XmlNode.InnerXml and Xml Readers / XmlDocument
- References:
- RE: XmlNode.InnerXml and Xml Readers / XmlDocument
- From: Steven Cheng[MSFT]
- RE: XmlNode.InnerXml and Xml Readers / XmlDocument
- Prev by Date: Re: why use .net?
- Next by Date: Re: Control the CPU Utilization during Application Execution written C
- Previous by thread: RE: XmlNode.InnerXml and Xml Readers / XmlDocument
- Next by thread: RE: XmlNode.InnerXml and Xml Readers / XmlDocument
- Index(es):
Relevant Pages
|