473,386 Members | 1,699 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

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.createElement('elementName')
docRootNode.appendChild(myElement)

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.createElement('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 2138
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.createElement('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
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" />...
4
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...
7
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>...
3
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....
7
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...
7
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...
14
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...
16
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...
1
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...
1
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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...
0
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...

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.