Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

The heart is not a logical organ. -- Dr. Janet Wallace, "The Deadly Years", stardate 3479.4


devel / comp.lang.php / Re: RDF parsing with php ( simplexml ? )

SubjectAuthor
o Re: RDF parsing with php ( simplexml ? )Shahab Ab

1
Re: RDF parsing with php ( simplexml ? )

<d9aeed24-c6e1-4470-bebc-30f2ad2f2ac3n@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=490&group=comp.lang.php#490

  copy link   Newsgroups: comp.lang.php
X-Received: by 2002:ac8:7f54:0:b0:2f1:f48c:c73a with SMTP id g20-20020ac87f54000000b002f1f48cc73amr4638010qtk.265.1650230587584;
Sun, 17 Apr 2022 14:23:07 -0700 (PDT)
X-Received: by 2002:a81:e24c:0:b0:2eb:4513:3793 with SMTP id
z12-20020a81e24c000000b002eb45133793mr7476084ywl.204.1650230587371; Sun, 17
Apr 2022 14:23:07 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.php
Date: Sun, 17 Apr 2022 14:23:07 -0700 (PDT)
In-Reply-To: <1192470617.796387.110720@e34g2000pro.googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=134.147.117.198; posting-account=ucvpfAoAAABS-y2Tg7g7dvZCBTKsw-cI
NNTP-Posting-Host: 134.147.117.198
References: <1192436594.121373.207920@z24g2000prh.googlegroups.com> <1192470617.796387.110720@e34g2000pro.googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d9aeed24-c6e1-4470-bebc-30f2ad2f2ac3n@googlegroups.com>
Subject: Re: RDF parsing with php ( simplexml ? )
From: shahab.ab2@gmail.com (Shahab Ab)
Injection-Date: Sun, 17 Apr 2022 21:23:07 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 47
 by: Shahab Ab - Sun, 17 Apr 2022 21:23 UTC

On Monday, October 15, 2007 at 7:50:17 PM UTC+2, NC wrote:
> On Oct 15, 1:23 am, matte...@mattelau.net wrote:
> >
> > Here is an XML file I'd like to parse with php.
> > It's a mozilla install.rdf file.
> >
> > <?xml version="1.0"?>
> > <RDF:RDF xmlns:em="http://www.mozilla.org/2004/em-rdf#"
> > xmlns:NC="http://home.netscape.com/NC-rdf#"
> > xmlns:RDF="http://www.w3.org/1999/02/22-rdf-syntax-ns#">
> > <RDF:Description RDF:about="urn:mozilla:install-manifest"
> > em:id="id1"
> > em:name="name1"
> > em:version="v1"
> > em:creator="creator1"
> > em:description="desc1"
> > em:homepageURL="home1"
> > em:updateURL="update1"
> > em:iconURL="icon1">
> > <em:targetApplication RDF:resource="rdf:#$b0tbb"/>
> > </RDF:Description>
> > <RDF:Description RDF:about="rdf:#$b0tbb"
> > em:id="id2"
> > em:minVersion="2.0"
> > em:maxVersion="2.0.0.*" />
> > </RDF:RDF>
> >
> > How would you do that ?
> > ( I'd like for example, to get the version associated with id1 )
> You wouldn't. Not with SimpleXML anyway. SimpleXML takes an XML file
> or string and converts it into an object. In RDF, however, XML
> entities' names contain colons, which are illegal in PHP variable
> names. You could try and replace colons with underscores, so you
> would get something like this:
> $RDF = file_get_contents('install.rdf');
> $RDF = str_replace('RDF:', 'RDF_', $RDF);
> $RDF = str_replace('em:', 'em_', $RDF);
> $XML = simplexml_load_string($RDF);
> foreach ($XML->RDF_Description as $num => $description) {
> $attributes = $description->attributes();
> if (isset($attributes['em_id'])) {
> echo "ID = {$attributes['em_id']}; version =
> {$attributes['em_version']}";
> }
> }
> Best regards,
> NC
and it's easily parsed !! :) Thank you!

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor