RE: XmlNode.InnerXml and Xml Readers / XmlDocument

Tech-Archive recommends: Fix windows errors by optimizing your registry



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
>
< <
" "
' &apos;

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 &apos;.

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.







.



Relevant Pages

  • Re: Word Searching XML
    ... which will be somewhat interactive and can not expected to load ... we are trying to search XML node and its ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.office.developer.com.add_ins)
  • Re: SQL2005, validation, & XQuery
    ... The xml in my sample columns only *had* one node: ... with the query I thought it might be related to the default namespace so I ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.sqlserver.xml)
  • Re: How to fomat table columns as attributes rather than elements
    ... data control as the DataGrid or DataGridView. ... asp.net use xml with attributes. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.adonet)
  • Re: How to fomat table columns as attributes rather than elements
    ... data control as the DataGrid or DataGridView. ... asp.net use xml with attributes. ... Microsoft Online Community Support ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.adonet)
  • RE: XmlDataSource & Website Proxy
    ... As for the XmlDataSource control, it doesn't expose a property for us to ... string based Xml content mostly. ... Microsoft MSDN Online Support Lead ... where an initial response from the community or a Microsoft Support ...
    (microsoft.public.dotnet.framework.aspnet)