473,757 Members | 10,263 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Building a XML file thanks to a XPath-like syntax

Hi all,

I would like to build a xml file using Xerces. I know how to build a
single node at a time.
For example, with 'doc' belonging to the DocumentImpl class and with
'docRootNode' belonging to the ElementNSImpl class, I do:

myElement = doc.createEleme nt('elementName ')
docRootNode.app endChild(myElem ent)

However, what I would like to be able to do is to use a XPath-like
syntax to build my xml file. Something of the type:

myElement = doc.createEleme nt('parentName/elementName')

where on can recognize a XPath syntax in 'parentName/elementName'.

Is there a way to do so ?
What class of Xerces allows me to do that ?

Thanks a lot for your help,

Cédric

Mar 2 '07 #1
2 2161
As far as I know, there's no standard, or even common, tool which will
implicitly create intermediate elements. You get to invent it yourself.

--
Joe Kesselman / Beware the fury of a patient man. -- John Dryden
Mar 2 '07 #2
On Mar 2, 4:58 pm, "redcic" <cedric.lou...@ gmail.com>
wrote:
I would like to build a xml file using Xerces. I know how
to build a single node at a time.
However, what I would like to be able to do is to use a
XPath-like syntax to build my xml file. Something of the
type:

myElement = doc.createEleme nt('parentName/elementName')
That sounds like a rather bad idea to me. Why invent a
primitive, non-standard language, easily confused with
XPath, which *is* standard but addresses a wholly different
problem domain (to quote from the spec: 'XPath is a
language for addressing parts of an XML document'), and
incurring a penalty for parsing that language run-time?

Especially since a standard language for serializing XML
DOM Documents and XML DOM Document Fragments as plain text
already exists. Hint: it's called XML.
where on can recognize a XPath syntax in
'parentName/elementName'.
Like that's a good thing. How do you add attributes or text
nodes? What if someone experiences a braino and attempts to
stuff a predicate in your 'XPath' expression?
What class of Xerces allows me to do that ?
What gave you an idea a class like that would exist?

Either use XML (and suffer run-time performance penalty for
parsing it) or stuff all the elements you need created into
a container and iterate until blue in the face. This
'XPath' thingo you came up with combines the worst of both
worlds.

--
roy axenov

Mar 2 '07 #3

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

Similar topics

9
5764
by: ETL | last post by:
Hi, I have an xml document that feeds a treeview menu on my web site. The structure of the xml file is as follows. <XML type="text/xml"> <root> <a0 name="One"> <a0_0 html="Report 1" id="1" /> <a0_1 html="Report 2" id="2" /> <a0_2 html="Report 3" id="3" />
4
21210
by: Son KwonNam | last post by:
In XSLT, is this possible to get value from xml using XPath which is in XSLT variable? I mean XPath strings can be dynamic while XSL Transforming. If possible, How?? Because I'm not a native English speaker, it's quite hard to make the problem clear. Please see the following example.
7
20401
by: chris.millar | last post by:
The below xml is saved as a file, i want the quickest way in c# of reading just the DataSource section and returning it as a string, can anyone help me out. Cheers Chris. <NewDataSet> <DataSource> <name>Oracle</name> <IsMaster>0</IsMaster>
3
2763
by: ciaran.mchale | last post by:
Hi folks, I downloaded the binary version of Xerces C++ 2.7.0 for Windows and am using it to help me get up to speed with XML and XML Schema. So please excuse me if this is a "novice" question. In the samples/data directory, I ran the following command for all the files: DOMPrint -n -s -f -v=always <filename>
7
2000
by: John Bowman | last post by:
Hi All, I'm fairly new to XML, so I presume I'm doing something obviously dense here, but here it goes. Below is an XML file that was extracted from a test Windows Installer .MSP (patch) file using the MsiExtractPatchXMLData() method and directly written to disk as a test. On the surface, it seems to me to be valid XML since IE can load & display it. <MsiPatch xmlns="http://www.microsoft.com/msi/patch_applicability.xsd"...
7
1297
by: Elhanan | last post by:
hi.. i'm trying to figure out if i can include an extenal file of xml inside xslt, what i need is a configuration file which xslt can query duing transformation, (we are talking about a rather large document here. i thought about using document function, since i'm gonna thiis called about hunders of times i don't know the impact this would have on performance (does xsll keeps opening closing a file?)
14
7350
by: Rob Meade | last post by:
Hi all, I'm working on a project where there are just under 1300 course files, these are HTML files - my problem is that I need to do more with the content of these pages - and the thought of writing 1300 asp pages to deal with this doesn't thrill me. The HTML pages are provided by a training company. They seem to be "structured" to some degree, but I'm not sure how easy its going to be to parse the page.
16
3529
by: TT (Tom Tempelaere) | last post by:
Hi all, I created an XSD to define the structure of an XML file for my project. I made an XML file linked to the XSD using XmlSpy. The problem is that if I read the file using .NET XmlDocument and then query for the root element, the result is always null (1). However if I strip the root element of all attributes generated by XmlSpy, then there is no problem to find the root element with .NET XML classes (2). (1) The XML for which...
1
3280
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token" but i cannot find a solution for this. maybe someone of you people can tell me how to do this...
1
2604
by: Christian Rühl | last post by:
hey! what i wanna do sounds very simple at first, but it turned out to be a real bone crusher... i want to check if a treeView node is checked and if a correspondent node in my xml config file exists just to sort of synchronize them by changing the xml nodes attribute(s). somehow i always catch an exception "blabla has an invalid token" but i cannot find a solution for this. maybe someone of you people can tell me how to do this...
0
9489
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9298
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9906
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9885
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8737
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7286
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5172
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5329
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3829
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.