473,772 Members | 2,411 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Guru Advice Requested...

disclaimer - i'm an xml newb.

my new project requires me to parse through an xml document and
populate an html form with the values. this appears simple if the
number of elements were to stay constant, however, they don't. i might
have one <element> or three <element>.

i'm using php and i'm planning on using PHP's DOM XML to parse through
the document a (using foreach) to nab each value and store it into a
variable and use those variables to display input into my forms. of
course, i'll need to use foreach in order to create my form elements,
too.

my variables would be created as follows:

$element1
$elemtent2

where the numeral is created as i loop through the values.

does this sound reasonable? is their some kind of DOM XML magic that
is designed to handle this case with ease?

any help / guidance would be greatly appreciated.

Feb 17 '06 #1
3 1149
you could use an array
$elements = array()
array_push ( $elements, $elementValue );
numberOfElement s = count( $elements )
etc.

Is this what you are asking? This should be simple enough.

Feb 18 '06 #2

Skeets schrieb:
disclaimer - i'm an xml newb.

my new project requires me to parse through an xml document and
populate an html form with the values. this appears simple if the
number of elements were to stay constant, however, they don't. i might
have one <element> or three <element>.

i'm using php and i'm planning on using PHP's DOM XML to parse through
the document a (using foreach) to nab each value and store it into a
variable and use those variables to display input into my forms. of
course, i'll need to use foreach in order to create my form elements,
too.

my variables would be created as follows:

$element1
$elemtent2

where the numeral is created as i loop through the values.

does this sound reasonable? is their some kind of DOM XML magic that
is designed to handle this case with ease?

any help / guidance would be greatly appreciated.


i had nearly the same problem and solved it as follows:

first i load my XML-Data in an DOMDocument. Afterwards i label every
element with a numbered "name" tag using XPath-expression "//*".

that's it:

$xml = DOMDocument::lo ad($_GET["xml"]);
$XPath = new DOMXPath($xml);
$r = $XPath->query("//*");
for ($i=0;$i<$r->length;$i++) {
$r->item($i)->setAttribute(" name", $i);
}

For creating the form i recommend XSL.

Cheers,
Dominik

By sending the form you can recognize the data in the fields by that
name.

Feb 18 '06 #3
Skeets wrote:
i might
have one <element> or three <element>.
That is not a problem at all as there are methods like
$domDocument->getElementsByT agName('element ')
or
$someElement->getElementsByT agName('element ')
to give you a node list of those element nodes for further processing.
And there is the possibility to use XPath for more complicated selections.
my variables would be created as follows:

$element1
$elemtent2

where the numeral is created as i loop through the values.


Does not sound like an XML problem then, as said for the XML elements
you have a node list to process, other data structures you want to fill
then are not XML related and as already suggested PHP has arrays to
allow you to store data e.g.
$data = array();
$data[] = ...;
$data[] = ...;
will increase the length of the array with each assignment.

--

Martin Honnen
http://JavaScript.FAQTs.com/
Feb 19 '06 #4

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

Similar topics

9
1436
by: obhayes | last post by:
Hi, I have two tables Table A and B, below with some dummy data... Table A (contains specific unique settings that can be requested) Id, SettingName 1, weight 2, length Table B (contains the setting values, here 3 values relate to weight
3
1177
by: Richard | last post by:
Trying to wrap my brain around Regex for the first time... I need to be able to replace Sql @NamedParameters with "?" for compliance with an extremely lame 3rd party Odbc driver. I know that this should be fairly straighforward in Regex but I'm not a Regex guru. Does anybody know how to turn this {not real Sql but demonstrates my issue}: SELECT * FROM Customers WHERE State=@State AND LastName LIKE @LastName into this
4
1127
by: Tim::.. | last post by:
I have asked this question several times and can't seem to get the answer I am looking for! I am trying to create a form that responds dynamically to the users choises within the page. At the moment I have a dropdownlist that has the values 1-10 in it. What I want to happen is that when the user selects one of the values... lets say 3! Three parts of the form are repeated! This means that the three parts of the forms input id's have to...
67
2955
by: Scott M. | last post by:
Can anyone give me any ideas on why VS.NET 2003 running on XP Pro. (P4's with 1GB RAM) would take over 3 minutes to simply create a new ASP.NET Web Application on http://localhost? It seems that the IIS directory gets created right away, but it is not configured as an application directory until several minutes go by. Thanks, Scott M.
4
1619
by: Andrey | last post by:
Hi, I will be hiring a php guru to help us architect a highly scalable web site/web application; the problem is I am coming from Microsoft .NET world and not too much familiar with the platform. What kinds of questions would you advice to ask the person on the interview to see if he/she is: 1. Proficient with php 2. Proficient with MySQL (development, maybe some administration) 3. Has web app architecture skills and knows how to build...
0
10106
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...
0
9914
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8937
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
7461
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
6716
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5355
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
5484
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
3610
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2851
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.