Re: Namespace Issue with InnerXML



Thanks,
I know understand why I would need to transform the XML using XSLT.

I'm sure it's probably not a complex XSLT that can remove the root element
of an XML file but as I never used XMLT....
My real XML file is more complex , I'd like to create a generic XSLT which
only removes the root element.

Does someone knows a good reference to work with...

Thanks,
Antoine


"Martin Honnen" <mahotrash@xxxxxxxx> wrote in message
news:%23v%23UiESWIHA.4548@xxxxxxxxxxxxxxxxxxxxxxx
Antoine Fromentin wrote:
Using C# I need to remove the root element of an xml document and keep
the inner XML document as is.x

<root xmlns="http://pjc.BizTalk";>
<ns0:LaunchStoreUpload xmlns:ns0="http://pjc.schemas";>
<Source>
<FTPParams>A</FTPParams>
</Source>
</ns0:LaunchStoreUpload>
</root>

Whatever I try :
root.RemoveAttribute("xmlns", "http://pjc.BizTalk";);
root.RemoveAllAttributes();
root.SetAttribute("xmlns", "");

when I use the root.InnerXML I obtain the following result

<ns0:LaunchStoreUpload xmlns:ns0="http://pjc.schemas";>
<Source xmlns="http://pjc.BizTalk";>
<FTPParams>A</FTPParams>
</Source>
</ns0:LaunchStoreUpload>

That's really not good for me, I don't want the extra
xmlns=http://pjc.BizTalk added in the <Source> node


Sorry, your approach can't work, the namespace of an node in the DOM model
is determined by its NamespaceURI property and you can't change that.
Deleting any xmlns attributes on ancestors does not help, you can't change
the namespace of a node.
You might want to look into XSLT to transform the XML. If you need help
with that then let us know.


--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/


.



Relevant Pages

  • Re: Editing XML
    ... I wonder how text and child nodes are distinguished in the XML text. ... The first is the processing instruction, which you'll typically ignore in XSLT. ... THe next is the element node named "tag" and the last is the text node. ... There is always exactly one root element in a valid XML document. ...
    (comp.lang.pascal.delphi.misc)
  • Re: Using PHP to parse specific XML tag content?
    ... XML --> HTML transformation in testing environment. ... run just fine under Windows using Cygwin, and, unless I'm ... but you have to learn XSLT or use whatever defaults ...
    (comp.lang.php)
  • Subject: ANN: 4Suite XML 1.0b2
    ... 4Suite XML - XML, XPath, XSLT, related technologies and support ... 4Suite RDF - RDF processing libraries and stand-alone DBMS ...
    (comp.lang.python.announce)
  • EditiX 2.1 - XML Editor & XSLT Debugger
    ... We are glad to announce the availability of EditiX 2.1. ... cross-platform and easy to use XML Editor and XSLT Debugger designed to ... New docking windows for the XSLT Editor ...
    (comp.lang.java.softwaretools)
  • Re: What is/is not considered to be good OO programming
    ... Brit programmers have common sense, ... XSLT is overblown and introduces ... Then your guys haven't learnt how to use XSL properly. ... > but XML, then use XSLT to style this output for the end user. ...
    (comp.lang.php)

Quantcast