473,324 Members | 2,179 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,324 software developers and data experts.

Creating an XML document based on XPath statements

Nice tool!

I am looking for something that will do the reverse. I have a whole bunch
of XPath statements and I need to use them to generate and populate an XML
document. I have mapping file that maps my data to a specific XPath. For
example:

Field# XPath
1 /LOAN/_APPLICATION/ASSET/@_Type
2
/LOAN/_APPLICATION/RESPA_FEE/_PAYMENT/@_IncludedInAPRIndicator

etc.

Do I have to parse every line myself or is there a .NET class that will do
this for me?
Aug 29 '06 #1
1 1672
I was hoping to find a function such as CreateAttribute(string XPath, string
data). For example:

CreateAttribute("/LOAN/_APPLICATION/ASSET/@_Type","Automobile") would create
the attribute and all needed parents if they don't exist:

<LOAN>
<_APPLICATION>
<ASSET _Type="Automobile">
</ASSET>
</_APPLICATION>
</LOAN>

If later on in the code I have this statement:
CreateAttribute("/LOAN/_APPLICATION/DOWN_PAYMENT/@_Type","CashOnHand"), it
will modify the above XML doc to:

<LOAN>
<_APPLICATION>
<ASSET _Type="Automobile">
</ASSET>
<DOWN_PAYMENT _Type="CashOnHand">
</DOWN_PAYMENT>
</_APPLICATION>
</LOAN>

In this following case, the function has to be smart enough to realize that
<ASSETalready has a _Type attribute, so it should create a new <ASSET>
element:
CreateAttribute("/LOAN/_APPLICATION/ASSET/@_Type","Automobile")

<LOAN>
<_APPLICATION>
<ASSET _Type="Automobile">
</ASSET>
<ASSET _Type="Automobile">
</ASSET>
<DOWN_PAYMENT _Type="CashOnHand">
</DOWN_PAYMENT>
</_APPLICATION>
</LOAN>

The tricky part now is to add nodes to an existing ASSET. I guess that
since both nodes look the same, we can add a node to either one:
CreateAttribute("/LOAN/_APPLICATION/ASSET/@_Type=\"Automobile\"/DESCRIPTION/@_Make","BMW")

<LOAN>
<_APPLICATION>
<ASSET _Type="Automobile">
<DESCRIPTION _Make="BMW">
</DESCRIPTION>
</ASSET>
<ASSET _Type="Automobile">
</ASSET>
<DOWN_PAYMENT _Type="CashOnHand">
</DOWN_PAYMENT>
</_APPLICATION>
</LOAN>

What abaout the year?
CreateAttribute("/LOAN/_APPLICATION/ASSET/@_Type=\"Automobile\"/DESCRIPTION/@_Make=\"BMW\"/@_Year","2006")

<LOAN>
<_APPLICATION>
<ASSET _Type="Automobile">
<DESCRIPTION _Make="BMW" _Year="2006">
</DESCRIPTION>
</ASSET>
<ASSET _Type="Automobile">
</ASSET>
<DOWN_PAYMENT _Type="CashOnHand">
</DOWN_PAYMENT>
</_APPLICATION>
</LOAN>

So I need to use String.Split() and walk the resulting array. I'll split at
'\'. I think I can use XPath to find an embeded node (i.e. ASSET inside
_APPLICATION inside LOAN). The thing is that I need to find the correct
ASSET node and the only thing that will differentiate them is what's on the
inside. Oh brother! This is going to be fun....

Any suggestions?
"Yossi" <jo**********@firstfi.comwrote in message
news:uw**************@TK2MSFTNGP05.phx.gbl...
Nice tool!

I am looking for something that will do the reverse. I have a whole bunch
of XPath statements and I need to use them to generate and populate an XML
document. I have mapping file that maps my data to a specific XPath. For
example:

Field# XPath
1 /LOAN/_APPLICATION/ASSET/@_Type
2 /LOAN/_APPLICATION/RESPA_FEE/_PAYMENT/@_IncludedInAPRIndicator

etc.

Do I have to parse every line myself or is there a .NET class that will do
this for me?

Aug 29 '06 #2

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

Similar topics

3
by: gfrommer | last post by:
Hello Everyone, I'm writing a server in java, and I want the clients to pass me an XPath query. I want the XPath queries to be in a specific format though, I'm pretty sure it's valid but I want...
3
by: Richard Fritzler | last post by:
I was given the task of designing a complete web based document prep system. In simplest terms (using a msword explanation) create a database of merge fields, and a library of templates. Allow the...
4
by: Iain | last post by:
I've an xml document that looks a bit like this <Vendors> <Vendor Stationery="Fred" /> <Vendor Stationery="bert" /> <Vendor Stationery="bert" /> </Vendors> I want to extract a list of the...
1
by: Chris Kennedy | last post by:
How do create a dataset from scratch based on an XML schema. This will not be filled by a dataadapter. It will be a dataset which I add rows to and then save as an XML file. All the example depend...
0
by: Mark Broadbent | last post by:
can someone help me? After creating an xml schema file in VS 2003, I drag and drop a table onto it to create its schema. However what I am getting is a document element encapsulating the actual...
0
by: Mark Broadbent | last post by:
(firstly sorry Ive cross posted this in C# forum also -I forgot to include this ng) can someone help me? After creating an xml schema file in VS 2003, I drag and drop a table onto it to create...
7
by: Michael Williams | last post by:
Hi All, I'm looking for a quality Python XML implementation. All of the DOM and SAX implementations I've come across so far are rather convoluted. Are there any quality implementations that...
2
by: Andy | last post by:
Hi, I have an XML document that uses namespaces (it is from a Word 2007 file). I want to retrieve all the "t" elements that belong to the "w" namespace (<w:t>) using XPath from VB.NET 2003 (.NET...
2
by: ajayreddy2105 | last post by:
Hi All, I want to build the xpath expression dynamically in the xsl for for-each. Scenario is like this:: 1. From javascript I am sending the parameters to xsl. 2. In xsl I am taking those...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.