472,989 Members | 2,658 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

Namespace agnostic parser?

I need to be able to read some element values and populate some
element values for some XML documents submitted to a service, but I can
not predict the NameSpace in the documents.

I have been using the System.Xml.XmlDocument object with success for
a known NameSpace and using the NameSpaceManager object with it. Is
there a way to Load some XML into the DOM and manipulate it without
having to know the Namespace?
I need to read and write into the elements.

TIA
- Brian

Jun 16 '06 #1
3 1542
* br***********@gmail.com wrote in microsoft.public.dotnet.xml:
I need to be able to read some element values and populate some
element values for some XML documents submitted to a service, but I can
not predict the NameSpace in the documents.

I have been using the System.Xml.XmlDocument object with success for
a known NameSpace and using the NameSpaceManager object with it. Is
there a way to Load some XML into the DOM and manipulate it without
having to know the Namespace?


Your question does not really make sense to me, the XML parser and the
XmlDocument implementation should not care about namespaces in a way
that hinders you to apply generic processing. Could you give a minimal
example of what you would like to do and why it does not work?
--
Björn Höhrmann · mailto:bj****@hoehrmann.de · http://bjoern.hoehrmann.de
Weinh. Str. 22 · Telefon: +49(0)621/4309674 · http://www.bjoernsworld.de
68309 Mannheim · PGP Pub. KeyID: 0xA4357E78 · http://www.websitedev.de/
Jun 17 '06 #2


br***********@gmail.com wrote:
I need to be able to read some element values and populate some
element values for some XML documents submitted to a service, but I can
not predict the NameSpace in the documents.

I have been using the System.Xml.XmlDocument object with success for
a known NameSpace and using the NameSpaceManager object with it. Is
there a way to Load some XML into the DOM and manipulate it without
having to know the Namespace?
I need to read and write into the elements.


If you know the element names but not the namespace then you could use
XPath expressions alike e.g.
//*[local-name() = 'the-element-name-here']
to find elements.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 17 '06 #3
Thanks all. Must have been my void of XPath knowledge at play here.
I was trying to write something like

SelectSingleNode("//ns1:OrderId")

without having to register "ns1" in the namespace manager object.

I have since resolved to use

string xPathPrefix = xmlDocument.DocumentElement.Prefix;

string xNameSpace = xmlDocument.DocumentElement.Attributes["xmlns:" +
xPathPrefix].Value;

And plowing forward into the NamespaceManager usage from there.
Allows me to not need to know the specifics of namespaces, atleast so
far.

Martin Honnen wrote:
br***********@gmail.com wrote:
I need to be able to read some element values and populate some
element values for some XML documents submitted to a service, but I can
not predict the NameSpace in the documents.

I have been using the System.Xml.XmlDocument object with success for
a known NameSpace and using the NameSpaceManager object with it. Is
there a way to Load some XML into the DOM and manipulate it without
having to know the Namespace?
I need to read and write into the elements.


If you know the element names but not the namespace then you could use
XPath expressions alike e.g.
//*[local-name() = 'the-element-name-here']
to find elements.
--

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


Jun 21 '06 #4

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

Similar topics

6
by: Robert Warnestam | last post by:
I've two class libraries, where one is referencing the other. The first library looks like this; (assembly name and root name space is set to Codab.Parser) namespace Codab.Parser { public class...
1
by: toton | last post by:
Hi, Is it possible to have a class level namespace opening instead of file level . Something like this, I have a long namespace like namespace com { namespace my_company{ namespace...
3
by: toton | last post by:
Hi, Is it possible to have a class level namespace opening instead of file level . Something like this, I have a long namespace like namespace com { namespace my_company{ namespace...
2
by: yllanger | last post by:
Hi guys, I have come yet again to ask another question. :D The scenario is like this. Using Parser; namespace Crawler { public void Main() {
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
4
NeoPa
by: NeoPa | last post by:
Hello everyone. I find myself stuck trying to find the VBA way to get Access to create a PDF of the currently-selected (and open) object (Form or Report). I know it can be done by selecting :...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
4
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...
3
SueHopson
by: SueHopson | last post by:
Hi All, I'm trying to create a single code (run off a button that calls the Private Sub) for our parts list report that will allow the user to filter by either/both PartVendor and PartType. On...

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.